Page 1 of 1

ExecSQL: Read result from INSERT with RETURNING clause

Posted: Wed 04 Mar 2009 12:15
by syagrius
Hello,

I want to migrate my application from PostgresDAC.
Sometimes I use INSERT with a RETURNING clause.
Please take a look at my query:

Code: Select all

INSERT INTO operat(ticket, oplogin)
VALUES (nextval('counter'),'syagrius')
RETURNING ticket;
My query is simple (and without parameter).
So I tried to use a PgConnection.ExecSQL(MyQuery, []).
But ExecSQL returns nothing.

How can I read the resulting field (or record)?

My English is not good so I can PM a little project if you need it.
Regards
Syagrius

Posted: Thu 05 Mar 2009 08:27
by Plash
You should use the TPgQuery component. Assign your SQL to the SQL property, call the Open method, and read the returned values from the fields of TPgQuery.