Subject Re: [IBO] Re: How to use bookmarks like tTable and tQuery?
Author Thomas Steinmaurer
> SET TERM ^ ;
>
> CREATE TRIGGER TRIG_AGENDA_BI_0 FOR AGENDA
> ACTIVE BEFORE INSERT POSITION 0
> AS BEGIN
> NEW.REGISTRO_ID = GEN_ID(GEN_AGENDA_REGISTRO_ID,1);
> END
> ^
>
> SET TERM ; ^

Thought so. Extend that to:

SET TERM ^ ;

CREATE TRIGGER TRIG_AGENDA_BI_0 FOR AGENDA
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.REGISTRO_ID IS NULL) THEN
NEW.REGISTRO_ID = GEN_ID(GEN_AGENDA_REGISTRO_ID,1);
END
^

SET TERM ; ^


And you will be fine, because REGISTRO_ID won't get a new value again,
thus IBO will have the correct value of REGISTRO_ID for a newly inserted
record.


--
HTH,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com