Subject | Re: Cannot create simple trigger??? |
---|---|
Author | dleec45 |
Post date | 2004-05-24T22:02:28Z |
--- In firebird-php@yahoogroups.com, Helen Borrie <helebor@t...> wrote:
confusion is live and well as I'm new to FB and have just about
everything to learn!! Lee
> At 06:24 AM 23/05/2004 +0000, you wrote:can
> >I'm trying to crate some simple triggers and am getting an error that
> >appears that GEN_ID is not recognized. Here's the trigger:
> >
> >SET TERM !! ;
> >CREATE TRIGGER Trg_Address_ID
> >FOR Address
> >BEFORE INSERT AS
> >NEW.ID GEN_ID(addr_gen_id, 1);
> >END !!
> >SET TERM ; !!
> >
> >and it blows up on GEN_ID!! Isn't this the correct format?
>
> "Format"? It's actually invalid PSQL.
>
> Try this:
> SET TERM !! ;
> CREATE TRIGGER Trg_Address_ID
> FOR Address
> BEFORE INSERT AS
> begin
> if (new.ID is null) then
> NEW.ID = GEN_ID(addr_gen_id, 1);
> END !!
> SET TERM ; !!
>
> Of course, you must have already created the generator:
>
> CREATE GENERATOR addr_gen_id;
> commit;
>
> Also, know that generators - unlike EVERYTHING ELSE in Firebird - are
> outside transaction control. Some of your later posts indicate great
> confusion here. If you get a value from a generator, it's
> yours. Generators don't roll back if they are unused; two requests
> never acquire the same value from the same generator. (As long as youThanks Helen, I did get the = sign in there finally and yes,
> don't meddle with the generator, of course!!)
>
> Helen
confusion is live and well as I'm new to FB and have just about
everything to learn!! Lee