Passign CSV to Params?

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Passign CSV to Params?

Post by yozey » Tue 21 Apr 2009 19:51

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?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 22 Apr 2009 06:53

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)

yozey
Posts: 32
Joined: Sat 17 Jan 2009 14:41

Post by yozey » Wed 22 Apr 2009 12:16

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.

Post Reply