Subject Re: [ib-support] Retreiving the ID of the last recird added.
Author Helen Borrie
At 03:27 PM 14-06-02 +0000, you wrote:
>Hi all,
>I am trying to get the ID for the last record added to a table.
>For example - when adding a record to a Customer table I use a
>trigger to generate an integer ID number for that record. I then want
>to get that number immediately.
>Is there a function to do this ?

If your client needs to know it, then it needs to get it *before* the row
is inserted and include it in the insert list. Write a query to get it
(or use an IDE function if your app devel environment provides one) and
change your trigger to

if (new.ID is null) then
new.ID = gen_id(MyGen, 1);

Welcome to Multiuserville!


All for Open and Open for All
Firebird Open SQL Database · ·