1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
| CREATE OR REPLACE FUNCTION to_word_fr(pn$nombre IN NUMBER)
RETURN VARCHAR2
AS
BEGIN
RETURN translate_fr(to_word_en(pn$nombre));
END to_word_fr;
/
CREATE OR REPLACE FUNCTION to_euro_fr(pn$nombre IN NUMBER)
RETURN VARCHAR2
AS
lv$entier VARCHAR2(255) := TRUNC(TO_NUMBER (REPLACE (pn$nombre, ' ', '')));
lv$decimales VARCHAR2(255) := SUBSTR (pn$nombre - lv$entier, 2);
li$nb_zero INTEGER := INSTR(TRANSLATE(SUBSTR (pn$nombre - lv$entier, 2),'123456789','xxxxxxxxx'),'x')-1;
lv$unite VARCHAR2(20) := ' euro';
lv$sous_unite VARCHAR2(20) := ' centime';
BEGIN
lv$entier := to_word_fr(TO_NUMBER(lv$entier));
IF ROUND(pn$nombre) > 1 THEN
lv$entier := lv$entier || lv$unite || 's ';
ELSE
lv$entier := lv$entier || lv$unite || ' ';
END IF;
IF lv$decimales IS NOT NULL THEN
lv$decimales := to_word_fr(TO_NUMBER(lv$decimales));
lv$entier := lv$entier || 'et ';
--ajoute les zeros après la virgule
IF li$nb_zero > 0 THEN
FOR i IN 1..li$nb_zero LOOP
lv$decimales := 'zero ' || lv$decimales;
END LOOP;
END IF;
IF pn$nombre - TRUNC(TO_NUMBER (REPLACE (pn$nombre, ' ', ''))) > 0.1 THEN
lv$decimales := lv$decimales || lv$sous_unite || 's';
ELSE
lv$decimales := lv$decimales || lv$sous_unite;
END IF;
END IF;
RETURN REPLACE(lv$entier || lv$decimales, ' ', ' ');
END to_euro_fr;
/
CREATE OR REPLACE FUNCTION to_word_en(pn$nombre IN NUMBER)
RETURN VARCHAR2
AS
--
TYPE table_varchar IS TABLE OF VARCHAR2 (255);
--
lv$multiples table_varchar := table_varchar ('',
' thousand ',
' million ',
' billion ',
' trillion ',
' quadrillion ',
' quintillion ',
' sextillion ',
' septillion ',
' octillion ',
' nonillion ',
' decillion ',
' undecillion ',
' duodecillion ',
' tridecillion ',
' quaddecillion ',
' quindecillion ',
' sexdecillion ',
' septdecillion ',
' octdecillion ',
' nondecillion ',
' dedecillion '
);
lv$entier VARCHAR2(255) := TRUNC (TO_NUMBER (REPLACE (pn$nombre, ' ', '')));
lv$decimales VARCHAR2(255) := SUBSTR (pn$nombre - lv$entier, 2);
lv$mots_complets VARCHAR2(4000);
lv$entier_lettres VARCHAR2(4000);
li$nb_zero INTEGER := INSTR(TRANSLATE(SUBSTR(pn$nombre - lv$entier, 2),'123456789','xxxxxxxxx'),'x')-1;
BEGIN
--
-- Traitement de la partie décimale
--
IF NVL (lv$decimales, 0) != 0
THEN
FOR i IN 1 .. lv$multiples.COUNT
LOOP
EXIT WHEN lv$decimales IS NULL;
--
IF (SUBSTR (lv$decimales, LENGTH (lv$decimales) - 2, 3) <> 0)
THEN
lv$mots_complets :=
TO_CHAR (TO_DATE (SUBSTR (lv$decimales,
LENGTH (lv$decimales) - 2,
3
),
'j'
),
'jsp'
)
|| lv$multiples (i)
|| lv$mots_complets;
END IF;
lv$decimales := SUBSTR (lv$decimales, 1, LENGTH (lv$decimales) - 3);
END LOOP;
IF li$nb_zero > 0 THEN
FOR i IN 1..li$nb_zero LOOP
lv$mots_complets := 'zero ' || lv$mots_complets;
END LOOP;
END IF;
-- Annonce la décimale (remplacer par Euro pour les montants en euros par exemple)
lv$mots_complets := ' point ' || lv$mots_complets;
END IF;
--
-- Traitement de la partie entière
--
IF NVL (lv$entier, 0) = 0
THEN
lv$mots_complets := 'zero' || lv$mots_complets;
ELSE
FOR i IN 1 .. lv$multiples.COUNT
LOOP
EXIT WHEN lv$entier IS NULL;
--
IF (SUBSTR (lv$entier, LENGTH (lv$entier) - 2, 3) <> 0)
THEN
lv$mots_complets :=
TO_CHAR (TO_DATE (SUBSTR (lv$entier, LENGTH (lv$entier) - 2,
3),
'j'
),
'jsp'
)
|| lv$multiples (i)
|| lv$mots_complets;
END IF;
lv$entier := SUBSTR (lv$entier, 1, LENGTH (lv$entier) - 3);
END LOOP;
END IF;
RETURN lv$mots_complets;
END to_word_en;
/
CREATE OR REPLACE FUNCTION to_word_fr(pn$nombre IN NUMBER)
RETURN VARCHAR2
AS
BEGIN
RETURN translate_fr(to_word_en(pn$nombre));
END to_word_fr;
/
CREATE OR REPLACE FUNCTION to_word_en(pn$nombre IN NUMBER)
RETURN VARCHAR2
AS
--
TYPE table_varchar IS TABLE OF VARCHAR2 (255);
--
lv$multiples table_varchar := table_varchar ('',
' thousand ',
' million ',
' billion ',
' trillion ',
' quadrillion ',
' quintillion ',
' sextillion ',
' septillion ',
' octillion ',
' nonillion ',
' decillion ',
' undecillion ',
' duodecillion ',
' tridecillion ',
' quaddecillion ',
' quindecillion ',
' sexdecillion ',
' septdecillion ',
' octdecillion ',
' nondecillion ',
' dedecillion '
);
lv$entier VARCHAR2(255) := TRUNC (TO_NUMBER (REPLACE (pn$nombre, ' ', '')));
lv$decimales VARCHAR2(255) := SUBSTR (pn$nombre - lv$entier, 2);
lv$mots_complets VARCHAR2(4000);
lv$entier_lettres VARCHAR2(4000);
li$nb_zero INTEGER;
BEGIN
--
-- Traitement de la partie décimale
--
IF NVL (lv$decimales, 0) != 0
THEN
FOR i IN 1 .. lv$multiples.COUNT
LOOP
EXIT WHEN lv$decimales IS NULL;
--
IF (SUBSTR (lv$decimales, LENGTH (lv$decimales) - 2, 3) <> 0)
THEN
lv$mots_complets :=
TO_CHAR (TO_DATE (SUBSTR (lv$decimales,
LENGTH (lv$decimales) - 2,
3
),
'j'
),
'jsp'
)
|| lv$multiples (i)
|| lv$mots_complets;
END IF;
lv$decimales := SUBSTR (lv$decimales, 1, LENGTH (lv$decimales) - 3);
END LOOP;
--ajoute les zeros après la virgule
li$nb_zero := INSTR(TRANSLATE(SUBSTR(pn$nombre - lv$entier, 2),'123456789','xxxxxxxxx'),'x')-1;
IF li$nb_zero > 0 THEN
FOR i IN 1..li$nb_zero LOOP
lv$mots_complets := 'zero ' || lv$mots_complets;
END LOOP;
END IF;
-- Annonce la décimale (remplacer par Euro pour les montants en euros par exemple)
lv$mots_complets := ' point ' || lv$mots_complets;
END IF;
--
-- Traitement de la partie entière
--
IF NVL (lv$entier, 0) = 0
THEN
lv$mots_complets := 'zero' || lv$mots_complets;
ELSE
FOR i IN 1 .. lv$multiples.COUNT
LOOP
EXIT WHEN lv$entier IS NULL;
--
IF (SUBSTR (lv$entier, LENGTH (lv$entier) - 2, 3) <> 0)
THEN
lv$mots_complets :=
TO_CHAR (TO_DATE (SUBSTR (lv$entier, LENGTH (lv$entier) - 2,
3),
'j'
),
'jsp'
)
|| lv$multiples (i)
|| lv$mots_complets;
END IF;
lv$entier := SUBSTR (lv$entier, 1, LENGTH (lv$entier) - 3);
END LOOP;
END IF;
RETURN lv$mots_complets;
END to_word_en;
/
CREATE OR REPLACE FUNCTION translate_fr(pv$nombre_en IN VARCHAR2)
RETURN VARCHAR2
AS
lv$nombre_fr VARCHAR2(255);
lv$entier VARCHAR2(255);
lv$decimale VARCHAR2(255);
BEGIN
lv$nombre_fr := REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(
REPLACE( REPLACE( REPLACE(
pv$nombre_en
, 'million' , 'millions' )
, 'billion' , 'milliards' )
, 'trillion' , 'trillions' )
, 'quadrillion' , 'quadrillions' )
, 'quintillion' , 'cintillions' )
, 'sextillion' , 'sextillions' )
, 'septillion' , 'septillions' )
, 'octillion' , 'octillions' )
, 'nonillion' , 'nonillions' )
, 'decillion' , 'decillions' )
, 'thousand' , 'mille' )
, 'hundred' , 'cent' )
, 'ninety' , 'quatre-vingt-dix')
, 'eighty' , 'quatre-vingts' )
, 'seventy' , 'soixante-dix' )
, 'sixty' , 'soixante' )
, 'fifty' , 'cinquante' )
, 'forty' , 'quarante' )
, 'thirty' , 'trente' )
, 'twenty' , 'vingt' )
, 'nineteen' , 'dix-neuf' )
, 'eighteen' , 'dix-huit' )
, 'seventeen' , 'dix-sept' )
, 'sixteen' , 'seize' )
, 'fifteen' , 'quinze' )
, 'fourteen' , 'quatorze' )
, 'thirteen' , 'treize' )
, 'twelve' , 'douze' )
, 'eleven' , 'onze' )
, 'ten' , 'dix' )
, 'nine' , 'neuf' )
, 'eight' , 'huit' )
, 'seven' , 'sept' )
, 'five' , 'cinq' )
, 'four' , 'quatre' )
, 'three' , 'trois' )
, 'two' , 'deux' )
, 'one' , 'un' )
, 'dix-six' , 'seize' )
, 'dix-cinq' , 'quinze' )
, 'dix-quatre' , 'quatorze' )
, 'dix-trois' , 'treize' )
, 'dix-deux' , 'douze' )
, 'dix-un' , 'onze' )
, '-un ' , '-une ' )
, 'un cent' , 'cent' )
, 'une' , 'un' )
, 'soixante-onze' , 'soixante et onze')
, 'quatre-vingts-' , 'quatre-vingt-' )
, '-un' , ' et un' )
, 'quatre-vingt et un', 'quatre-vingt-un' )
, 'deux cent' , 'deux cents' )
, 'trois cent' , 'trois cents' )
, 'quatre cent' , 'quatre cents' )
, 'cinq cent' , 'cinq cents' )
, 'six cent' , 'six cents' )
, 'sept cent' , 'sept cents' )
, 'huit cent' , 'huit cents' )
, 'neuf cent' , 'neuf cents' )
, 'cents ' , 'cent ' )
, 'vingts mille' , 'vingt mille' )
, 'un millions' , 'un million' )
, 'un bidecillions' , 'un bidecillion' )
, 'un cintillions' , 'un cintillion' )
, 'un milliards' , 'un milliard' )
, 'un trillions' , 'un trillion' )
, 'un quadrillions' , 'un quadrillion' )
, 'un sextillions' , 'un sextillion' )
, 'un septillions' , 'un septillion' )
, 'un octillions' , 'un octillion' )
, 'un nonillions' , 'un nonillion' )
, 'un decillions' , 'un decillion' )
, 'un undecillions' , 'un undecillion' )
, 'un duodecillions' , 'un duodecillion' )
, 'un tridecillions' , 'un tridecillion' )
, 'un quaddecillions' , 'un quaddecillion' )
, 'un quindecillions' , 'un quindecillion' )
, 'un sexdecillions' , 'un sexdecillion' )
, 'un septdecillions' , 'un septdecillion' )
, 'un octdecillions' , 'un octdecillion' )
, 'un nondecillions' , 'un nondecillion' )
, 'un dedecillions' , 'un dedecillion' )
, '-un trillion' , '-un trillions' )
, '-un quadrillion' , '-un quadrillions' )
, '-un sextillion' , '-un sextillions' )
, '-un septillion' , '-un septillions' )
, '-un octillion' , '-un octillions' )
, '-un nonillion' , '-un nonillions' )
, '-un decillion' , '-un decillions' )
, '-un undecillion' , '-un undecillions' )
, '-un duodecillion' , '-un duodecillions' )
, '-un tridecillion' , '-un tridecillions' )
, '-un quaddecillion' , '-un quaddecillions')
, '-un quindecillion' , '-un quindecillions')
, '-un sexdecillion' , '-un sexdecillions' )
, '-un septdecillion' , '-un septdecillions')
, '-un octdecillion' , '-un octdecillions' )
, '-un nondecillion' , '-un nondecillions' )
, '-un dedecillion' , '-un dedecillions' )
, '-un million' , '-un millions' )
, '-un bidecillion' , '-un bidecillions')
, '-un cintillion' , '-un cintillions' )
, '-un milliard' , '-un milliards' )
, ' cent millions' , ' cents millions' )
, ' cent bidecillions' , ' cents bidecillions' )
, ' cent cintillions' , ' cents cintillions' )
, ' cent milliards' , ' cents milliards' )
, ' cent trillions' , ' cents trillions' )
, ' cent quadrillions' , ' cents quadrillions' )
, ' cent sextillions' , ' cents sextillions' )
, ' cent septillions' , ' cents septillions' )
, ' cent octillions' , ' cents octillions' )
, ' cent nonillions' , ' cents nonillions' )
, ' cent decillions' , ' cents decillions' )
, ' cent centdecillions' , ' cents centdecillions' )
, ' cent duodecillions' , ' cents duodecillions' )
, ' cent tridecillions' , ' cents tridecillions' )
, ' cent quaddecillions' , ' cents quaddecillions' )
, ' cent quindecillions' , ' cents quindecillions' )
, ' cent sexdecillions' , ' cents sexdecillions' )
, ' cent septdecillions' , ' cents septdecillions' )
, ' cent octdecillions' , ' cents octdecillions' )
, ' cent nondecillions' , ' cents nondecillions' )
, ' cent dedecillions' , ' cents dedecillions' )
, 'et un million' , 'et un millions' )
, 'et un bidecillion' , 'et un bidecillions' )
, 'et un cintillion' , 'et un cintillions' )
, 'et un milliard' , 'et un milliards' )
, 'et un trillion' , 'et un trillions' )
, 'et un quadrillion' , 'et un quadrillions' )
, 'et un sextillion' , 'et un sextillions' )
, 'et un septillion' , 'et un septillions' )
, 'et un octillion' , 'et un octillions' )
, 'et un nonillion' , 'et un nonillions' )
, 'et un decillion' , 'et un decillions' )
, 'et un undecillion' , 'et un undecillions' )
, 'et un duodecillion' , 'et un duodecillions' )
, 'et un tridecillion' , 'et un tridecillions' )
, 'et un quaddecillion' , 'et un quaddecillions' )
, 'et un quindecillion' , 'et un quindecillions' )
, 'et un sexdecillion' , 'et un sexdecillions' )
, 'et un septdecillion' , 'et un septdecillions' )
, 'et un octdecillion' , 'et un octdecillions' )
, 'et un nondecillion' , 'et un nondecillions' )
, 'et un dedecillion' , 'et un dedecillions' )
, 'cent un million' , 'cent un millions' )
, 'cent un bidecillion' , 'cent un bidecillions' )
, 'cent un cintillion' , 'cent un cintillions' )
, 'cent un milliard' , 'cent un milliards' )
, 'cent un trillion' , 'cent un trillions' )
, 'cent un quadrillion' , 'cent un quadrillions' )
, 'cent un sextillion' , 'cent un sextillions' )
, 'cent un septillion' , 'cent un septillions' )
, 'cent un octillion' , 'cent un octillions' )
, 'cent un nonillion' , 'cent un nonillions' )
, 'cent un decillion' , 'cent un decillions' )
, 'cent un undecillion' , 'cent un undecillions' )
, 'cent un duodecillion' , 'cent un duodecillions' )
, 'cent un tridecillion' , 'cent un tridecillions' )
, 'cent un quaddecillion' , 'cent un quaddecillions' )
, 'cent un quindecillion' , 'cent un quindecillions' )
, 'cent un sexdecillion' , 'cent un sexdecillions' )
, 'cent un septdecillion' , 'cent un septdecillions' )
, 'cent un octdecillion' , 'cent un octdecillions' )
, 'cent un nondecillion' , 'cent un nondecillions' )
, 'cent un dedecillion' , 'cent un dedecillions' )
, 'point' , 'virgule' )
,' ',' ');
IF INSTR(lv$nombre_fr,'virgule') > 0 THEN
lv$entier := SUBSTR(lv$nombre_fr, 1, INSTR(lv$nombre_fr,'virgule')-2);
lv$decimale := SUBSTR(lv$nombre_fr, INSTR(lv$nombre_fr,'virgule') - 1);
ELSE
lv$entier := lv$nombre_fr;
lv$decimale := NULL;
END IF;
IF lv$entier LIKE '%un mille%'
AND NOT (lv$entier LIKE '%cent% un mille%' OR lv$entier LIKE '%et un mille%' OR lv$entier LIKE '%-un mille%')
THEN
lv$entier := REPLACE(lv$entier, 'un mille', 'mille');
END IF;
RETURN lv$entier || lv$decimale;
END translate_fr;
/ |
Partager