Subject Re: Little problem with generators
Author Adam
--- In firebird-support@yahoogroups.com, "andrew_s_vaz"
<andrew_s_vaz@...> wrote:
>
> Hi all,
>
> How can I know if a Generator of name "whatever" already exists? I
> need to create generators automatically and I'm slightly stumped
with
> this.
>
> Thanks
> Andrew
>

1. Attempt to get a value from it, and if you get an exception that
it is not there, then create it.

select gen_id(whatever, 0) from RDB$DATABASE;

2. Issue a create command and ignore any exception

Create generator whatever;

3. Interrogate System tables

select
case when exists
(
select *
from RDB$GENERATORS
WHERE Upper(RDB$GENERATOR_NAME) = Upper('whatever')
)
then 'T' else 'F' end as GeneratorExists
from RDB$DATABASE;

** Note: Do not attempt to manipulate the system tables directly,
treat them as read-only or risk database confetti **

Adam