Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Bonjour,
je suis confronté de à un problème de filtre...
Je m'explique: J'essaie de faire un filtre sur 2 champs(l'un de type varchar et l'autre de type number) d'une datawindows.
Le problème est que lorsque j'exécute, une erreur apparaît avec pour message Excepting TRUE/FALSE Expression.
Pourtant mon code à l'air de fonctionner....
Voilà le bout de code que j'effectue
dw_parametre.setredraw(false) dw_parametre.SetFilter( "l_parametre LIKE '%" + this.text + "%' and i_parametre = 12") dw_parametre.Filter() dw_parametre.Setredraw(true)
Merci de votre aide
Dernière modification par krimo (21-04-2010 13:16:32)
Hors ligne
Bonjour,
On ne peut pas utiliser d'expression SQL dans un filtre, mais des expressions datawindows valides :
dw_parametre.SetFilter("match('" + this.text + "') and i_parametre = 12")
Hors ligne
le LIKE est accepté :
LIKE and NOT LIKE operators
Use LIKE to search for strings that match a predetermined pattern. Use NOT LIKE to search for strings that do not match a predetermined pattern. When you use LIKE or NOT LIKE, you can use the % or _ characters to match unknown characters in a pattern.
For example, the following expression for the Background.Color property of the Salary column displays salaries in red for employees with last names beginning with F and displays all other salaries in white:
If(emp_lname LIKE'F%',RGB(255,0,0),RGB(255,255,255))
Escape keyword
If you need to use the % or _ characters as part of the string, you can use the escape keyword to indicate that the character is part of the string. For example, the _ character in the following filter string is part of the string to be searched for, but is treated as a wildcard:
comment LIKE ~'%o_a15progress%~'
The escape keyword designates any character as an escape character (do not use a character that is part of the string you want to match). In the following example, the asterisk (*) character is inserted before the _ character and designated as an escape character, so that the _ character is treated as part of the string to be matched:
comment like ~'%o*_a15progress%~' escape ~'*~'
NB : la balise de code PB est en minuscules [ code=pb ] (sans les espaces) et non [ code langage =PB]
Hors ligne
Bonjour,
Effectivement, j'ai été un peu vite pour répondre comme tu as pu le voir .
J'avais en tête cette réponse car de souvenir il me semblait avoir déjà eu ce genre de problème et je l'avais contourné en remplaçant par un match.
Hors ligne
Effectivement, les deux solutions fonctionnent ^^
Merci pour l'aide
Hors ligne
OK cool. Petites précisions sur les règles pour poster :
un espace après le [RESOLU] et :
erasorz a écrit:
[ code=pb ] (sans les espaces) et non [ code langage =PB]
Hors ligne