bonjour,
je veux convertir un montant (en number) à un montant en toutes lettres.
bonjour,
je veux convertir un montant (en number) à un montant en toutes lettres.
Bonjour,
Quelle relation avec Forms ?
recherchez dans la FAQ PL/SQL. je crois qu'il existe une entrée dans ce sens.
merci mais quand je fais
SELECT translate_fr(to_word_en(7480.230)) FROM dual;
il m'affiche sept mille quatre cent quatre-vingts vingt-trois
et moi je veux afficher
sept mille quatre cent quatre-vingts deux cent-trente
aussi je veux que la procedure accepte les virgules et non les points
et merci infiniment
Il te suffit d'adapter le code pour prendre un VARCHAR à la place d'un NUMBER
Essaye :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 CREATE OR REPLACE FUNCTION nb_en_lettre(pv$nombre IN VARCHAR) RETURN VARCHAR2 AS ln$entier NUMBER := TO_NUMBER(SUBSTR(pv$nombre,1,INSTR(pv$nombre,',')-1)); ln$decimales VARCHAR2 (255) := TO_NUMBER(SUBSTR(pv$nombre,INSTR(pv$nombre,',')+1)); BEGIN RETURN translate_fr(to_word_en(ln$entier))|| ' ' || translate_fr(to_word_en(ln$decimales)); END; /
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 SQL> select nb_en_lettre('7480,230') from dual; NB_EN_LETTRE('7480,230') -------------------------------------------------------------------------------- sept mille quatre cent quatre-vingts deux cent trente
merci beucoup
mais j'ai un autre petit probleme
quand j'ai un montant de 7 480,300 et qui est stocké dans la base 7480,3
en principe il m'affiche
sept milleS quatre centS quatre-vingts DINARS trois centS MILLIMES
mais il m'affiche
sept mille quatre cent quatre-vingts DINARS trois MILLIMES
aussi tu remarques que le 'S' du CENTS n'est pas affiché
c'est un bug, essaye avec :
j'ai ajouté 2 REPLACE :
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 CREATE OR REPLACE FUNCTION translate_fr(pn$nombre_en in varchar2) RETURN VARCHAR2 AS BEGIN RETURN REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE( REPLACE(REPLACE( pn$nombre_en , 'million' , 'millions' ) , 'billion' , 'milliards' ) , 'trillion' , 'trillions' ) , 'quadrillion' , 'quadrillions' ) , 'quintillion' , 'cintillions' ) , 'sextillion' , 'sextillions' ) , 'septillion' , 'septillions' ) , 'octillion' , 'octillions' ) , 'nonillion' , 'nonillions' ) , 'decillion' , 'decillions' ) , 'undecillion' , 'undecillions' ) , 'duodecillion' , 'duodecillions' ) , 'tridecillion' , 'tridecillions' ) , 'quaddecillion' , 'quaddecillions' ) , 'quindecillion' , 'quindecillions' ) , 'sexdecillion' , 'sexdecillions' ) , 'septdecillion' , 'septdecillions' ) , 'octdecillion' , 'octdecillions' ) , 'nondecillion' , 'nondecillions' ) , 'dedecillion' , 'dedecillions' ) , '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' ) , 'un mille' , 'mille' ) , '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 ' ) , ' mille' , ' un 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' ) , 'point' , 'virgule' ) ,' ',' ') ; END translate_fr; /
, ' mille' , ' un mille' pour ajouter un si mille n'est pas le premier mot (si il est précédé d'un espace)
,' ',' ' pour supprimer les espaces en trop
Voila qui devrait aller :
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 CREATE OR REPLACE FUNCTION translate_fr(pn$nombre_en IN varchar2) RETURN VARCHAR2 AS lv$nombre_fr VARCHAR2(32000); 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( pn$nombre_en , 'million' , 'millions' ) , 'billion' , 'milliards' ) , 'trillion' , 'trillions' ) , 'quadrillion' , 'quadrillions' ) , 'quintillion' , 'cintillions' ) , 'sextillion' , 'sextillions' ) , 'septillion' , 'septillions' ) , 'octillion' , 'octillions' ) , 'nonillion' , 'nonillions' ) , 'decillion' , 'decillions' ) , 'undecillion' , 'undecillions' ) , 'duodecillion' , 'duodecillions' ) , 'tridecillion' , 'tridecillions' ) , 'quaddecillion' , 'quaddecillions' ) , 'quindecillion' , 'quindecillions' ) , 'sexdecillion' , 'sexdecillions' ) , 'septdecillion' , 'septdecillions' ) , 'octdecillion' , 'octdecillions' ) , 'nondecillion' , 'nondecillions' ) , 'dedecillion' , 'dedecillions' ) , '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 ' ) , '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' ) , 'point' , 'virgule' ) ,' ',' '); IF SUBSTR(lv$nombre_fr,1,8)='un mille' THEN lv$nombre_fr := SUBSTR(lv$nombre_fr,4); END IF; RETURN lv$nombre_fr; END translate_fr; /
merci beucoup
mais j'ai un autre petit probleme
quand j'ai un montant de 7 480,300 et qui est stocké dans la base 7480,3
en principe il m'affiche
sept milleS quatre centS quatre-vingts DINARS trois centS MILLIMES
mais il m'affiche
sept mille quatre cent quatre-vingts DINARS trois MILLIMES
aussi tu remarques que le 'S' du CENTS n'est pas affiché
c'est normal, vérifie les règles d'orthographe
Mille est invariable et cent ne se conjugue que si il n'est pas suivi de dizaine ou unité (deux cents mais deux cent dix )
ok, je dois reviser mon orthographe.
mais j'ai un autre petit probleme
quand j'ai un montant de 7 480,300 et qui est stocké dans la base 7480,3
en principe il m'affiche
sept mille quatre cent quatre-vingts DINARS trois cents MILLIMES
mais il m'affiche
sept mille quatre cent quatre-vingts DINARS trois MILLIMES
c'est normal, si tu ne veux pas avoir ce problème c'est à toi d'ajouter les 0.
pourquoi ne pas stocker en VARCHAR2 dans la base le contenu de l'item tout bêtement ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part SUBSTR(ta_colonne || '000', 1, INSTR(ta_colonne,',')+3)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 SQL> SELECT NB_EN_LETTRE(SUBSTR('&a' || '000', 1, INSTR('&a',',')+3)) FROM dual 2 ; Enter value for a: 7950000,7 Enter value for a: 7950000,7 old 1: SELECT NB_EN_LETTRE(SUBSTR('&a' || '000', 1, INSTR('&a',',')+3)) FROM dual new 1: SELECT NB_EN_LETTRE(SUBSTR('7950000,7' || '000', 1, INSTR('7950000,7',',')+3)) FROM dual NB_EN_LETTRE(SUBSTR('7950000,7'||'000',1,INSTR('7950000,7',',')+3)) -------------------------------------------------------------------------------- sept millions neuf cent cinquante mille virgule sept cents
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager