Page 1 of 1

Passign CSV to Params?

Posted: Tue 21 Apr 2009 19:51
by yozey
Is this possible to receive this result?

Code: Select all

PgQuery.ParamByName('ids').AsString := '1,2,3';
When I want the database to get the SQL like

Code: Select all

SELECT * FROM employee WHERE id IN(1,2,3)
from a PgQuery.SQL.Text that contains

Code: Select all

'SELECT * FROM employee WHERE employee_id IN (:ids)'
or do I have to create separate parameters for all the values I'm looking for?

Posted: Wed 22 Apr 2009 06:53
by Plash
No, you cannot use one parameter for the value list of IN expression.

You can create separate parameters for each value. You can also use a macro instead of parameter:

Code: Select all

SELECT * FROM employee WHERE employee_id IN (&ids)

Posted: Wed 22 Apr 2009 12:16
by yozey
Ok thanks a lot for the macro tip. I'm currently building each parameter but supposed the macros will save me a lot of time.