Subject Re: more questions on use of generators
Author Milan Babuskov
> From: Helen Borrie <helebor@...>
> Subject: Re: more questions on use of generators
>
> RDB$Database just happens to be "any old table that has one and only
> one row". You could create your own table to use instead, if you
> preferred, as long as you had some way (e.g. a trigger) to ensure
> that it would always have one and only one row.
>
> We all use RDB$Database because it's there. If it's InterBase you're
> using, not Firebird, be alerted that Borl have indicated that they
> might at some point prevent user queries on RDB$Database.

I have a table DUMMY in all my databases, I use the following DDL to create
it:

CREATE TABLE DUMMY (
FOOBAR INTEGER NOT NULL
);

ALTER TABLE DUMMY ADD check (foobar = 1);
ALTER TABLE DUMMY ADD PRIMARY KEY (FOOBAR);
GRANT SELECT ON DUMMY TO PUBLIC;

Later, I just do:
SELECT GEN_ID(GENERATOR_NAME, 1) FROM DUMMY;

You can also add a trigger to prevent users from deleting that single row
from DUMMY table.

Just my $0.02

Milan Babuskov
http://sourceforge.net/projects/fbexport