IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SQL Oracle Discussion :

oracle + convertir chiffres en lettres


Sujet :

SQL Oracle

  1. #41
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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; 
    /
    Pour l'euro, je l'ai fait rapidos, c'est probablement perfectible

  2. #42
    Expert confirmé
    Avatar de laurentschneider
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2005
    Messages
    2 944
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2005
    Messages : 2 944
    Points : 4 926
    Points
    4 926
    Par défaut
    tu n'as pas corrigé les grand nombres

    SELECT to_word_fr(1e12) FROM dual;
    un trillion

    et aussi, le truc de cent%, c'est pas bon...

    SELECT to_word_fr(100001000) FROM dual;
    cent millions un mille

  3. #43
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    1 trillion c'est bon

    Et sinon :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    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;
     
        IF lv$entier LIKE '%lion un mille%' OR lv$entier LIKE '%liard un mille%' OR lv$entier LIKE '%lions un mille%' OR lv$entier LIKE '%liards un mille%' 
    	 THEN
           lv$entier := REPLACE(lv$entier, 'un mille', 'mille');
        END IF;
     
        RETURN lv$entier || lv$decimale;
     
    END translate_fr; 
    /

  4. #44
    Expert confirmé
    Avatar de laurentschneider
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2005
    Messages
    2 944
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2005
    Messages : 2 944
    Points : 4 926
    Points
    4 926
    Par défaut
    SELECT to_word_fr (.1001001)
    FROM dual;
    FAUX: zero virgule un million un mille un
    JUSTE: zero virgule un million mille un

    SELECT to_word_fr (1e12)
    FROM dual;
    FAUX: un trillion
    JUSTE: un billion

    bonne semaine

  5. #45
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    D'après l'échelle courte ou régle latine c'est bien trillion

    http://www.miakinen.net/vrac/nombres

    Après, c'est assez ouvert le nommage, alors on va pas chipoter hein

    Sinon, pour les décimales corrigées :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE FUNCTION translate_fr(pv$nombre_en IN VARCHAR2) 
    RETURN VARCHAR2 
    AS
       lv$nombre_fr VARCHAR2(4000); 
       lv$entier VARCHAR2(4000); 
       lv$decimale VARCHAR2(4000); 
    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;
     
        lv$nombre_fr := lv$entier || lv$decimale;
     
        IF lv$nombre_fr LIKE '%un mille%' 
    	 AND NOT (lv$nombre_fr LIKE '%cent% un mille%' OR lv$nombre_fr LIKE '%et un mille%' OR lv$nombre_fr LIKE '%-un mille%')
    	 THEN
           lv$nombre_fr := REPLACE(lv$nombre_fr, 'un mille', 'mille');
        END IF;
     
        IF lv$nombre_fr LIKE '%lion un mille%' OR lv$nombre_fr LIKE '%liard un mille%' OR lv$nombre_fr LIKE '%lions un mille%' OR lv$nombre_fr LIKE '%liards un mille%' 
    	 THEN
           lv$nombre_fr := REPLACE(lv$nombre_fr, 'un mille', 'mille');
        END IF;
     
        RETURN lv$nombre_fr;
     
    END translate_fr; 
    /
    Par contre, j'aime pas trop le 0.10 qui s'écrit zero virgule un... je vais corriger ça

  6. #46
    Modérateur
    Avatar de Waldar
    Homme Profil pro
    Customer Success Manager @Vertica
    Inscrit en
    Septembre 2008
    Messages
    8 452
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Customer Success Manager @Vertica
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2008
    Messages : 8 452
    Points : 17 820
    Points
    17 820
    Par défaut
    Aparement vous avez un mélange des deux règles !

    Si vous dites milliard pour 10^9 alors vous dites billion pour 10^12.

    Et d'après votre lien :
    "le 3 mai 1961, l'échelle longue devient la seule légale en France."

  7. #47
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Voila :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    CREATE OR REPLACE FUNCTION to_word_fr(pv$nombre IN VARCHAR) 
       RETURN VARCHAR2 
    AS
    BEGIN
      RETURN translate_fr(to_word_en(pv$nombre));
    END to_word_fr;
    /
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    CREATE OR REPLACE FUNCTION to_word_en(pv$nombre IN VARCHAR) 
       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 (pv$nombre, ' ', ''))); 
       lv$decimales        VARCHAR2(255); 
       lv$mots_complets    VARCHAR2(4000); 
       lv$entier_lettres   VARCHAR2(4000); 
       li$nb_zero          INTEGER := INSTR(TRANSLATE(SUBSTR(pv$nombre - lv$entier,2),'123456789','xxxxxxxxx'),'x')-1; 
    BEGIN
     
    SELECT DECODE(INSTR(pv$nombre, '.'),0,NULL, SUBSTR (pv$nombre,INSTR(pv$nombre, '.')+1))
      INTO lv$decimales FROM dual;
       -- 
       -- 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; 
    /
    Le paramètre est désormais en VARCHAR
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    SQL> SELECT to_word_fr('0.10') from dual;
     
    TO_WORD_FR('0.10')
    -------------------------------------------------------------
    zero virgule dix
    Le NUMBER est autorisé mais ignore les 0 qui termine la décimale.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    SQL> SELECT to_word_fr(0.10) from dual;
     
    TO_WORD_FR(0.10)
    ---------------------------------------------------------------
    zero virgule un
    Du coup :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE FUNCTION to_euro_fr(pv$nombre IN VARCHAR) 
       RETURN VARCHAR2 
    AS
    lv$entier     VARCHAR2(255) := TRUNC(TO_NUMBER (REPLACE (pv$nombre, ' ', ''))); 
    lv$decimales  VARCHAR2(255);
    li$nb_zero    INTEGER := INSTR(TRANSLATE(SUBSTR (pv$nombre - lv$entier, 2),'123456789','xxxxxxxxx'),'x')-1; 
    lv$unite      VARCHAR2(20) := ' euro';
    lv$sous_unite VARCHAR2(20) := ' centime';
    BEGIN
      SELECT DECODE(INSTR(pv$nombre, '.'),0,NULL, SUBSTR (pv$nombre,INSTR(pv$nombre, '.')+1))
        INTO lv$decimales FROM dual;
     
      lv$entier := to_word_fr(lv$entier);
     
      IF ROUND(pv$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(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 pv$nombre - TRUNC(TO_NUMBER (REPLACE (pv$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;
    /
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    SQL> SELECT to_euro_fr('0.10') from dual;
     
    TO_EURO_FR('0.10')
    ------------------------------------------------------------------------------
    zero euro et dix centime
     
    SQL> SELECT to_euro_fr('0.100') from dual;
     
    TO_EURO_FR('0.100')
    ------------------------------------------------------------------------------
    zero euro et cent centime

  8. #48
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Citation Envoyé par Waldar Voir le message
    Aparement vous avez un mélange des deux règles !

    Si vous dites milliard pour 10^9 alors vous dites billion pour 10^12.

    Et d'après votre lien :
    "le 3 mai 1961, l'échelle longue devient la seule légale en France."
    trahi par mon propre lien

    je corrige tout ça alors c'est beaucoup plus compliqué du coup

  9. #49
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Ca corrige pas mal de chose mais pas complétement :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE FUNCTION translate_fr(pv$nombre_en IN VARCHAR2) 
    RETURN VARCHAR2 
    AS
       lv$nombre_fr VARCHAR2(4000); 
       lv$entier VARCHAR2(4000); 
       lv$decimale VARCHAR2(4000); 
    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'          , 'billions'       ) 
                                                 , 'quadrillion'       , 'billiards'    ) 
                                                 , 'quintillion'       , 'trillions'     ) 
                                                 , 'sextillion'        , 'trilliards'     )    
                                                 , 'septillion'        , 'quadrillions'     )  
                                                 , 'octillion'         , 'quadrilliards'      ) 
                                                 , 'nonillion'         , 'quintillions'      )  
                                                 , 'decillion'         , 'quintilliards'      )  
                                                 , '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 trillions'    , 'un trillion'   ) 
                                                 , 'un milliards'      , 'un milliard'     ) 
                                                 , 'un trillions'      , 'un billion'      ) 
                                                 , 'un quadrillions'   , 'un billiard'   ) 
                                                 , 'un trilliards'    , 'un trilliard'    )    
                                                 , 'un quadrillions'    , 'un quadrillion'    )  
                                                 , 'un quadrilliards'     , 'un quadrilliard'     ) 
                                                 , 'un quintillions'     , 'un quintillion'     )  
                                                 , '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 billions'     ) 
                                                 , '-un quadrillion'   , '-un billiards'  ) 
                                                 , '-un trilliard'    , '-un trilliards'   )    
                                                 , '-un quadrillion'    , '-un quadrillions'   )  
                                                 , '-un quadrilliard'     , '-un quadrilliards'    ) 
                                                 , '-un quintillion'     , '-un quintillions'    )  
                                                 , '-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 trillion'    , '-un trillions' ) 
                                                 , '-un milliard'      , '-un milliards'   ) 
                                                 , ' cent millions'       , ' cents millions'      ) 
                                                 , ' cent bidecillions'   , ' cents bidecillions'  ) 
                                                 , ' cent trillions'    , ' cents trillions'   ) 
                                                 , ' cent milliards'      , ' cents milliards'     ) 
                                                 , ' cent trillions'      , ' cents billions'      ) 
                                                 , ' cent quadrillions'   , ' cents billiards'   ) 
                                                 , ' cent trilliards'    , ' cents trilliards'    )    
                                                 , ' cent quadrillions'    , ' cents quadrillions'    )  
                                                 , ' cent quadrilliards'     , ' cents quadrilliards'     ) 
                                                 , ' cent quintillions'     , ' cents quintillions'     )  
                                                 , ' 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 trillion'    , 'et un trillions'   ) 
                                                 , 'et un milliard'      , 'et un milliards'     ) 
                                                 , 'et un trillion'      , 'et un billions'      ) 
                                                 , 'et un quadrillion'   , 'et un billiards'   ) 
                                                 , 'et un trilliard'    , 'et un trilliards'    )    
                                                 , 'et un quadrillion'    , 'et un quadrillions'    )  
                                                 , 'et un quadrilliard'     , 'et un quadrilliards'     ) 
                                                 , 'et un quintillion'     , 'et un quintillions'     )  
                                                 , '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 trillion'    , 'cent un trillions'   ) 
                                                 , 'cent un milliard'      , 'cent un milliards'     ) 
                                                 , 'cent un trillion'      , 'cent un billions'      ) 
                                                 , 'cent un quadrillion'   , 'cent un billiards'   ) 
                                                 , 'cent un trilliard'    , 'cent un trilliards'    )    
                                                 , 'cent un quadrillion'    , 'cent un quadrillions'    )  
                                                 , 'cent un quadrilliard'     , 'cent un quadrilliards'     ) 
                                                 , 'cent un quintillion'     , 'cent un quintillions'     )  
                                                 , '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;
     
        lv$nombre_fr := lv$entier || lv$decimale;
     
        IF lv$nombre_fr LIKE '%un mille%' 
    	 AND NOT (lv$nombre_fr LIKE '%cent% un mille%' OR lv$nombre_fr LIKE '%et un mille%' OR lv$nombre_fr LIKE '%-un mille%')
    	 THEN
           lv$nombre_fr := REPLACE(lv$nombre_fr, 'un mille', 'mille');
        END IF;
     
        IF lv$nombre_fr LIKE '%lion un mille%' OR lv$nombre_fr LIKE '%liard un mille%' OR lv$nombre_fr LIKE '%lions un mille%' OR lv$nombre_fr LIKE '%liards un mille%' 
    	 THEN
           lv$nombre_fr := REPLACE(lv$nombre_fr, 'un mille', 'mille');
        END IF;
     
        RETURN lv$nombre_fr;
     
    END translate_fr; 
    /
    Mais je pense que je vais juste ajouter une limitation aux chiffres inférieurs à 10^36

    d'ailleurs... ça fonctionne pas :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    SELECT to_word_fr('99999999999999999999999999999999999.99999999999') from dual;
     
    cent quintilliards virgule quatre-vingt-dix-neuf milliards neuf cent quatre-ving
    t-dix-neuf millions neuf cent quatre-vingt-dix-neuf mille neuf cent quatre-vingt
    -dix-neuf
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    SELECT to_word_fr('99999999999999999999999999999999999') from dual;
     
    quatre-vingt-dix-neuf quintilliards neuf cent quatre-vingt-dix-neuf quintillions
     neuf cent quatre-vingt-dix-neuf quadrilliards neuf cent quatre-vingt-dix-neuf q
    uadrillions neuf cent quatre-vingt-dix-neuf trilliards neuf cent quatre-vingt-di
    x-neuf trillions neuf cent quatre-vingt-dix-neuf billiards neuf cent quatre-ving
    t-dix-neuf billions neuf cent quatre-vingt-dix-neuf milliards neuf cent quatre-v
    ingt-dix-neuf millions neuf cent quatre-vingt-dix-neuf mille neuf cent quatre-vi
    ngt-dix-neuf
    A voir donc

  10. #50
    Modérateur
    Avatar de Waldar
    Homme Profil pro
    Customer Success Manager @Vertica
    Inscrit en
    Septembre 2008
    Messages
    8 452
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Customer Success Manager @Vertica
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2008
    Messages : 8 452
    Points : 17 820
    Points
    17 820
    Par défaut
    Je n'ai pas encore testé mais centime prend un 's' au-delà de un.
    C'est courageux en tout cas de faire cette fonction !

  11. #51
    Expert confirmé
    Avatar de laurentschneider
    Homme Profil pro
    Administrateur de base de données
    Inscrit en
    Décembre 2005
    Messages
    2 944
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Administrateur de base de données
    Secteur : Finance

    Informations forums :
    Inscription : Décembre 2005
    Messages : 2 944
    Points : 4 926
    Points
    4 926
    Par défaut


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    SQL> select to_word_fr(1000.101001) from dual
    un mille virgule cent un mille un             ==> mille virgule...    
    SQL> select to_word_fr(1100000000) from dual
    un milliard cents millions                        ==> pas de s à cent
    SQL> select to_word_fr(1e24) from dual
    un billiard                                       ==> un quadrillion
    SQL> select to_word_fr(1e33) from dual
    un quintilliards                                  ==> pas de s
    SQL> select to_word_fr(1e36) from dual
    un unquintilliards                               ==> sûrement pas...

  12. #52
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    j'ai introduit des régressions on dirait

    Je regarderai ça... merci encore de ton aide

  13. #53
    Nouveau Candidat au Club
    Inscrit en
    Février 2010
    Messages
    1
    Détails du profil
    Informations forums :
    Inscription : Février 2010
    Messages : 1
    Points : 1
    Points
    1
    Par défaut mekhlouf_mourad@yahoo.fr
    Citation Envoyé par florine Voir le message
    Bonjour,
    svp connaissez-vous une fonction en sql permettant de convertir des chiffres en lettres? ou bien quelqu'un en a-t-il un à me proposer? par exemple: convertir "1585" en "mille cinq cent quatre vingts cinq".*
    Merci

  14. #54
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    et qu'est ce qu'on doit faire de votre message exactement ?

  15. #55
    iam
    iam est déconnecté
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Novembre 2005
    Messages : 197
    Points : 72
    Points
    72
    Par défaut
    je suis tres reconnaissant pour le travail et l'effort que vous avez réalisé pour la conversion des chiffres en lettres, j'ai besoins de cette fonctionnalité pour afficher les montants en lettres dans mes factures, ça repond à mon besoin mais seulement un petit souci,

    je m'explique :

    quand je fais ca :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    select to_euro_fr('0.10') from dual;
    ca me fais cette erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ORA-06502:PL/SQL:erreur numérique ou erreur sur une valeur:erreur de conversion des caractères en chiffres
    ORA-06512:à "SCO.TO_EURO_FR",ligne 4
    je n'ai pas compris pourtant j'ai utilisé le code corrigé en dernier des fonctions to_euro_fr et to_word_fr , to_word_en, translate_fr

    je pense que le séparateur décimal me pose un problème parceque quand j'utilise la virgule :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    select to_euro_fr('0,10') from dual;
    il m'affiche mais je cherche à afficher
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    zero euro et dix centimes euros
    ou est ce qu'elle est l'erreur pourtant vous avez mis ce post résolu.
    merci pour votre attention

  16. #56
    iam
    iam est déconnecté
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Novembre 2005
    Messages : 197
    Points : 72
    Points
    72
    Par défaut
    aparement le problem est dans le séparateur décimal
    il faut mettre nls_numerci_character = .
    mais je ne sais pas comment le faire je travail avec forms et reports

  17. #57
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    un alter session devrait suffire

  18. #58
    iam
    iam est déconnecté
    Membre régulier
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    197
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Novembre 2005
    Messages : 197
    Points : 72
    Points
    72
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    DROP TRIGGER NLS_CONFIG_TRG;
     
    CREATE OR REPLACE TRIGGER NLS_CONFIG_TRG 
    AFTER LOGON ON DATABASE
    BEGIN
    execute immediate 'alter session set NLS_NUMERIC_CHARACTERS = ". "';
    END;
    /
    j'ai ajouté ce trigger dans la base de donnés mais ca n'a pa resolu mon pb, quand j'appel une facture avec des montant qui contient des décimal il m'affiche erreur frm-41214

    donc je veux forcer l'utilisation du point comme séparateur décimal au moment de l'appel de la facture ou bien au moment de l'appel de la fonction to_euro_fr une idée sur ca?

  19. #59
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Et si tu ajoutes l'alter session dans le package ?

  20. #60
    Expert éminent sénior
    Avatar de orafrance
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    15 967
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Janvier 2004
    Messages : 15 967
    Points : 19 073
    Points
    19 073
    Par défaut
    Citation Envoyé par laurentschneider Voir le message
    un billiard ==> un quadrillion
    SQL> select to_word_fr(1e33) from dual
    un quintilliards ==> pas de s
    SQL> select to_word_fr(1e36) from dual
    un unquintilliards ==> sûrement pas... [/code]
    C'est l'écriture pour l'échelle longue en vigueur en France

    http://fr.wikipedia.org/wiki/Trilliard

    http://fr.wikipedia.org/wiki/%C3%89c...9chelle_longue

+ Répondre à la discussion
Cette discussion est résolue.
Page 3 sur 4 PremièrePremière 1234 DernièreDernière

Discussions similaires

  1. [AC-2003] Convertir chiffres en lettres avec changement de la devise
    Par sbobo dans le forum VBA Access
    Réponses: 1
    Dernier message: 06/06/2013, 17h54
  2. convertir chiffre en lettre arabe
    Par infomap dans le forum VBA Access
    Réponses: 1
    Dernier message: 16/11/2011, 17h24
  3. convertir chiffre en lettre arabe
    Par infomap dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 26/04/2011, 19h39
  4. convertir chiffre en lettre arabe
    Par DzBadBoy dans le forum Langage
    Réponses: 13
    Dernier message: 21/09/2009, 21h46
  5. [VB]Convertir chiffres en lettres
    Par RichY dans le forum VB 6 et antérieur
    Réponses: 6
    Dernier message: 16/02/2006, 14h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo