Page 1 of 1

INSERT RETURNING

Posted: Thu 18 Feb 2010 23:29
by jrodenhi
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

Posted: Tue 23 Feb 2010 10:41
by Dimon
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;

Posted: Thu 25 Feb 2010 16:06
by jrodenhi
This works perfectly. Thanks.