Subject Re: [firebird-support] Generators Associated with a Table
Author Milan Babuskov
Lee Jenkins wrote:
>>>Is there a way to query the system tables to retrieve the generator (if
>>>any) that is being used by that table?

If you use triggers, I guess you can by looking at object dependencies.
I.e. a trigger depends on some table and some generator.

> I'm thinking about building an import utility that will bulk process
> INSERTS into a DB but don't want to get in trouble with the generators
> lagging behind cause PK violations.

You can still create "smart" before-insert trigger, which will first
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