Subject Re: [firebird-support] Creating a Generator Fails
Author Helen Borrie
At 02:37 PM 9/10/2009, you wrote:


>Hello
>
>I need some help. I have a database I exported from Access 97 into a Firebird 2.1 Database. I need to create a auto increment field. I cannot seem to create a Generator. I tried the following which seem to execute without failure but it does not show up in FlameRobin.
>
>When I try to create a trigger it fails and complains about missing generator. Is it possible to create a generator for a table with existing data?? If so how ??
>
>Here is my code:
>
>CREATE GENERATOR gen_tabADDRESS_ID;
>SET GENERATOR gen_tabADDRESS_ID TO 42659; (42659 is the last row)

Check whether FlameRobin actually created a generator called "gen_tabADDRESS_ID" (with the double-quotes). It will do that if you configure it to do it.

If so, then the identifier is case-sensitive and also won't work without the quotes in any future DDL, PSQL or DML reference. In that case, your SET GENERATOR statement would need to be

SET GENERATOR "gen_tabADDRESS_ID" TO 42659;

and your trigger would need to be

create trigger bi_tabAddress for tabAddress
active before insert as
begin
if (new.ADDRESS_ID is null) then
new.ADDRESS_ID = gen_id ("gen_tabADDRESS_ID", 1);
end

./heLen