Page 1 of 1

using parameter by where clause in ()

Posted: Thu 03 Nov 2011 09:42
by jkuiper
I want to use a parameter to findsome records.

Normally the query look likes this : 'select * from table where id in (1,2,3)', it wil gives the asked records.

In Delphi I use a parameter:

Code: Select all

Myquery1.SQL.Text := from table where id in (:id);
MyQuery1.Params[0].Value := eparams.text;
This results in: 'select * from table where id in ('1,2,3')'

Is there a way to get the proper value (1,2,3) when I use Params?

Posted: Thu 03 Nov 2011 10:41
by AndreyZ
Hello,

To avoid this problem, you should use macros instead of parameters. Here is an example:

Code: Select all

Myquery1.SQL.Text := 'select * from table where id in (&id)';
MyQuery1.Macros[0].Value := eparams.text;
MyQuery1.Open;
For more information about macros, please read the 'Working with Macros' topic of the MyDAC documentation.