Subject | Re: [firebird-support] Generators Associated with a Table |
---|---|
Author | Milan Babuskov |
Post date | 2003-11-11T15:17:35Z |
Lee Jenkins wrote:
I.e. a trigger depends on some table and some generator.
check for possible PK violation, an increase the generator, something
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 :temp;
set generator table1_gen to :temp + 1;
end
end
I wrote this from the top of my head, so syntax is wrong, but you'll get
the idea...
--
Milan Babuskov
http://fbexport.sourceforge.net
>>>Is there a way to query the system tables to retrieve the generator (ifIf you use triggers, I guess you can by looking at object dependencies.
>>>any) that is being used by that table?
I.e. a trigger depends on some table and some generator.
> I'm thinking about building an import utility that will bulk processYou can still create "smart" before-insert trigger, which will first
> INSERTS into a DB but don't want to get in trouble with the generators
> lagging behind cause PK violations.
check for possible PK violation, an increase the generator, something
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 :temp;
set generator table1_gen to :temp + 1;
end
end
I wrote this from the top of my head, so syntax is wrong, but you'll get
the idea...
--
Milan Babuskov
http://fbexport.sourceforge.net