Page 1 of 1

problem with macro

Posted: Mon 20 Feb 2012 11:09
by robertoicardi
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......

Posted: Mon 20 Feb 2012 13:17
by AlexP
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.

Posted: Mon 20 Feb 2012 14:08
by robertoicardi
That was!!! Thanks a lot :D

Posted: Mon 20 Feb 2012 14:19
by AlexP
Hello,

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