How to use TIBCQuery with parameters and "in" keyword
Posted: Fri 07 May 2021 14:05
I have a TIBCQuery. I'm using this SQL statement:
This gives me 7 records.
How to use this statement with parameters? I tried this:
It's executed, but the resultset is empty. It must return 7 records as the statement above. Is Values[x] the wrong way?
Code: Select all
MyQuery.SQL.Text := 'select * from MyTable where MyField in (''A'', ''B'', ''C'')';
How to use this statement with parameters? I tried this:
Code: Select all
MyQuery.SQL.Text := 'select * from MyTable where MyField in (:MyField)';
MyQuery.ParamByName('MyField').ValueCount := 3;
MyQuery.ParamByName('MyField').Values[0].AsString := 'A';
MyQuery.ParamByName('MyField').Values[1].AsString := 'B';
MyQuery.ParamByName('MyField').Values[2].AsString := 'C';