| Subject | Re: [firebird-support] Generators Associated with a Table | 
|---|---|
| Author | Milan Babuskov | 
| Post date | 2003-11-11T15:59:01Z | 
Martijn Tonies wrote:
I guess I forgot about that.
You could then just replace PK value with max(PK) + 1, like this:
create trigger tx1 for table1
before insert
as
begin
if exists (select * from table1 where pk = new.pk) then
begin
select max(pk) from table1 into new.pk;
end
end
--
Milan Babuskov
http://fbexport.sourceforge.net
            > SET GENERATOR isn't allowed in a trigger.:(
I guess I forgot about that.
You could then just replace PK value with max(PK) + 1, like this:
create trigger tx1 for table1
before insert
as
begin
if exists (select * from table1 where pk = new.pk) then
begin
select max(pk) from table1 into new.pk;
end
end
--
Milan Babuskov
http://fbexport.sourceforge.net