Subject Re: Select max(id) is slow ?
Author hannes@dwscript.com
--- In ib-support@y..., Carsten Schäfer <ca_schaefer@g...> wrote:
> ...auto-increment primary key (id_apos) on a table
> t_apos
> (generator gen_apos that is used in a before insert trigger).
> Now i want to put the new id that is given from the generator in my
> object that was inserted.

you could use a stored proc for inserting
query the generator in the SP and return the value.
(just e few lines more to write)
and skip the before insert trigger.

example:
CREATE PROCEDURE "Atable_ID_AutoInc" (pcol1 integer, pcol2 varchar..)
RETURNS (NEW_VALUE INTEGER)
AS
BEGIN
NEW_VALUE = GEN_ID(TAUTO_ID, 1);
insert into atable (id, col1, col2..)
values(NEW_VALUE , :pcol, pcil2..);
suspend;
END

hope thats what you want,
hannes hernler
--------------------------------------------------------
DWS - Delphi Web Script
developing professional web apps
look at http://www.dwscript.com
--------------------------------------------------------