INSERT RETURNING

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for InterBase & Firebird in Delphi and C++Builder
Post Reply
jrodenhi
Posts: 9
Joined: Thu 18 Feb 2010 23:17

INSERT RETURNING

Post by jrodenhi » Thu 18 Feb 2010 23:29

How can I retrieve the value from a statement like this:

Code: Select all

INSERT INTO INVOICE(dtStatement)
VALUES('01/31/2010')
RETURNING ID
I am using a TSQLQuery to execute the statement from Delphi 2006 on a Firebird 2.1 database.

Thank you for your help.

Jack

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 23 Feb 2010 10:41

To solve the problem you should add a new parameter to TSQLQuery with Name = 'ID' and ParamType = ptOutput. After this you can get ID value using the code:

Code: Select all

ID := SQLQuery.ParamByName('ID').Value;

jrodenhi
Posts: 9
Joined: Thu 18 Feb 2010 23:17

Post by jrodenhi » Thu 25 Feb 2010 16:06

This works perfectly. Thanks.

Post Reply