Subject | RE: [firebird-support] Generators Associated with a Table |
---|---|
Author | Thomas Steinmaurer |
Post date | 2003-11-11T07:23:16Z |
Lee,
for your database objects. For example, my autoinc generators
are named something like GEN_<TABLE>_ID, so for a table
ARTICLE this is GEN_ARTICLE_ID. If you are using such an
schema, then you could iterate through the RDB$GENERATORS
table, and parse for each generator - that follows that
notation rule - the table name, and query the actual
generator value with GEN_ID(generatorname, 0).
Though, when getting and/or resetting the generator value,
you should be the only one connected to the database.
HTH,
Best Regards,
Thomas Steinmaurer
Logging/Auditing Suites for InterBase, Firebird and Advantage Database Server
http://www.iblogmanager.com
http://www.adslogmanager.com
> > You probably use a generator to increment the value ofIt might be easy to do, if you are using a self-made notation
> > a primary key column for your table, but the generator
> > doesn't stand in any relationship to a table.
> >
> > That means, you can create a generator without having
> > any table in your database.
>
> So no way to figure out which generators, if any, a table is using...
> Makes sense, given the nature of generators. Hmmm. Maybe I could just
> use a separate table and store the values of the generator names there.
>
> 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.
for your database objects. For example, my autoinc generators
are named something like GEN_<TABLE>_ID, so for a table
ARTICLE this is GEN_ARTICLE_ID. If you are using such an
schema, then you could iterate through the RDB$GENERATORS
table, and parse for each generator - that follows that
notation rule - the table name, and query the actual
generator value with GEN_ID(generatorname, 0).
Though, when getting and/or resetting the generator value,
you should be the only one connected to the database.
HTH,
Best Regards,
Thomas Steinmaurer
Logging/Auditing Suites for InterBase, Firebird and Advantage Database Server
http://www.iblogmanager.com
http://www.adslogmanager.com