Filter in a SQL

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
jpnuage
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 02.03.2012, 11:03

Filter in a SQL

Post by jpnuage »

Hi folks, spring is coming soon....problems too :(

Please look at the following code.
for i := 1 to Length(Edit.Text) do begin

if Edit1.Text <> '' then
begin
xCode := RightStr(trim(Edit1.Text),5);
ClientDataSet2.Active := false;
ClientDataSet2.ParamByName('CodeArticle').AsString := xCode;
ClientDataSet2.Active := true;
ClientDataSet2.Refresh;

ch := CleEntete; // <--result of previous SQL ClientDataSet2
// looks like 1451,1568,1788,1888
// and may be more numbers
if ch = 'null' then
CDS.Filter := 'ID_ENTETE is null'
else
CDS.Filter := 'ID_ENTETE in (' + ch + ')' ;
CDS.Filtered := true;
CDS.Refresh;
end;
...... //<== rest of code
ID_ENTETE id an Integer.

I get the error message at execution :
Syntax error near in
I tried to replace 'ID_ENTETE in (' + ch + ')' by 'ID_ENTETE is in (1245,1266,1278)' just to see. Same message.

And I cannot work with the adding of filters in the SQL of CDS :wallb:

What is my code miswriting ?

Thank you for any help
josimarz
Junior Boarder
Junior Boarder
Posts: 41
Joined: 14.09.2009, 17:29
Location: Brazil

Post by josimarz »

Hello jpnuage,

Try use the OR operator:

Code: Select all

ID_ENTETE = 1245 OR ID_ENTETE = 1266 OR ID_ENTETE =1278
More about filters:

http://zeos.firmos.at/viewtopic.php?t=3 ... ght=filter

Josimar.
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Post by Pitfiend »

Which is the SQL engine you are using?
I use filters against MySQL without troubles, but only for strings using quotedstr() function around variables, never tried integers or anything else.
Did you try that instruction in an interactive client first?
Post Reply