Subject gen_id with trigger
Author Michele Federici
Hi,

I'm doing some test with generators. When I've a generator I add a
trigger as this:

CREATE TRIGGER BI_MYTABLE FOR MYTABLE
ACTIVE BEFORE INSERT
POSITION 0
AS
BEGIN
IF (NEW.ID_MYTABLE IS NULL) THEN
NEW.ID_MYTABLE = GEN_ID(MYTABLE_GEN, 1);
END

Now, i want that if client adds a record with value ID_MYTABLE > current
generator value, the generator must be updated to ID_MYTABLE value

CREATE TRIGGER BI_MYTABLE FOR MYTABLE
ACTIVE BEFORE INSERT
POSITION 0
AS
DECLARE VARIABLE ACTUAL_VALUE BIGINT;
BEGIN
IF (NEW.ID_MYTABLE IS NULL) THEN BEGIN
NEW.ID_MYTABLE = GEN_ID(MYTABLE_GEN, 1);
END ELSE BEGIN
ACTUAL_VALUE = GEN_ID(MYTABLE_GEN, 0 );
if (NEW.ID_MYTABLE > ACTUAL_VALUE) THEN BEGIN
ACTUAL_VALUE = GEN_ID(MYTABLE_GEN, NEW.ID_MYTABLE - ACTUAL_VALUE );
END
END
END^

Can i have some problem with concurrency?

Thank you

--
Michele Federici