Subject Re: [IBO] Determine table's key value after post
Author Helen Borrie
At 09:31 PM 7/05/2005 +0200, you wrote:
>I'm using an IBODatabase and IBOQuery components in an IntraWeb
>application interfacing with a FireBird database. I'm using a Generator
>and a Triger to generate the keys of the table. What is the best way to
>get hold of the generated key value in the AfterPost event of the IBOQuery?

There is no way to get it *after* the post. The trick is to get it
*before*, using GeneratorLinks.

Write the trigger in such a way that it will only fire if no value is
passed to it, i.e.

create trigger xx for yy active before insert
if (new.ID is null) then
new.ID = gen_id(gen_yy, 1);

Then, in your IBOQuery, set GeneratorLinks:


or set it globally in the GeneratorLinks property of your connection object:


You can read the value into a variable in the BeforePost event.