Salut
Je cherche à évaluer en booléen une expression stockée en chaine (ex: '3<4').
Si vous avez des solutions?
Merci d'avance.
Salut
Je cherche à évaluer en booléen une expression stockée en chaine (ex: '3<4').
Si vous avez des solutions?
Merci d'avance.
Salut
En attendant mieux, j'ai créé une fonction en plpgsql
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 CREATE OR REPLACE FUNCTION verifier(strentry text) RETURNS boolean AS $BODY$ declare strtemp text; i integer; gauche text; droite text; begin strtemp=btrim(strentry); If strtemp = '' Then return false; End If; if position('AND' in upper(strtemp))>0 then return verifier(btrim(left(strtemp,position('AND' in upper(strtemp))-1))) and verifier(btrim(right(strtemp,char_length(strtemp) - position('AND' in upper(strtemp))-3))); elsif position('OR' in upper(strtemp))>0 then return verifier(btrim(left(strtemp,position('OR' in upper(strtemp))-1))) OR verifier(btrim(right(strtemp,char_length(strtemp) - position('OR' in upper(strtemp))-2))); ELSE i=1; While i < char_length(strtemp) loop If position('<>' in strtemp) > 0 Then gauche= left(strtemp,position('<>' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('<>' in strtemp)-1); return (gauche::numeric <> droite::numeric)::boolean; exit; ElsIf position('<=' in strtemp) > 0 Then gauche= left(strtemp,position('<=' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('<=' in strtemp)-1); return (gauche::numeric <= droite::numeric)::boolean; exit; elsIf position('>=' in strtemp) > 0 Then gauche= left(strtemp,position('>=' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('>=' in strtemp)-1); return (gauche::numeric >= droite::numeric)::boolean; exit; elsIf position('>' in strtemp) > 0 Then gauche= left(strtemp,position('>' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('>' in strtemp)); return (gauche::numeric > droite::numeric)::boolean; exit; elsIf position('<' in strtemp) > 0 Then gauche= left(strtemp,position('<' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('<' in strtemp)); return (gauche::numeric < droite::numeric)::boolean; exit; elsIf position('=' in strtemp) > 0 Then gauche= left(strtemp,position('=' in strtemp)-1); droite= right(strtemp,char_length(strtemp)- position('=' in strtemp)); return (gauche::numeric = droite::numeric)::boolean; exit; else i=i+1; End If; end Loop; END IF; end $BODY$ LANGUAGE plpgsql IMMUTABLE
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