Subject | Re: [firebird-support] Generators Associated with a Table |
---|---|
Author | Martijn Tonies |
Post date | 2003-11-11T15:28:49Z |
Hi,
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> >>>Is there a way to query the system tables to retrieve the generator (ifSET GENERATOR isn't allowed in a trigger.
> >>>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
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com