ExecSQL: Read result from INSERT with RETURNING clause

Discussion of open issues, suggestions and bugs regarding PgDAC (PostgreSQL Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
syagrius
Posts: 10
Joined: Sat 28 Feb 2009 13:45

ExecSQL: Read result from INSERT with RETURNING clause

Post by syagrius » Wed 04 Mar 2009 12:15

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

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

Post by Plash » Thu 05 Mar 2009 08:27

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.

Post Reply