problem with macro

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
robertoicardi
Posts: 27
Joined: Wed 28 Jan 2009 11:29

problem with macro

Post by robertoicardi » Mon 20 Feb 2012 11:09

Hello, this is the first time I try to use macro, but I'm having a problem...

sql of a pgquery component is declared this way:

select * from table where field in &IN

then in code I prepare my string like this: S := '(1, 2, 3)' and assign S to the macro with pgquery1.macrobyname('IN').AsString := S

but when I try to open pgquery1 I receive an error.

Looking through dbmonitor I can see that macro get quoted inside SQL statement, so what is passed to postgresql is:

select * from table where field in '(1, 2, 3')'

I've tried to assign macro with AnsiDequotedStr(S) but (as I expected, by the way) didn't work.

Thanks for help......

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 20 Feb 2012 13:17

Hello,

As you set the macro to String (AsString := 'XXXX'), you will get a string instead of macro in the back-end query, and such behaviour is correct.
You should use MacroByName('IN').Value := '(1,2,3)'; construction for retrieving desired results.

robertoicardi
Posts: 27
Joined: Wed 28 Jan 2009 11:29

Post by robertoicardi » Mon 20 Feb 2012 14:08

That was!!! Thanks a lot :D

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 20 Feb 2012 14:19

Hello,

Glad to see that the problem was solved. If you have any other questions, feel free to contact us.

Post Reply