Subject | Re: Arg.. Autonum generator newbie question... |
---|---|
Author | cowmix3 |
Post date | 2005-03-07T22:45:59Z |
Ok.. I have the "Auto-Incrementing Keys" trigger working.. meaning
Firebird accepts the trigger without barfing..
However, it doesn't seem to be working.
If I insert a column, the auto-increment trigger should magically
work, right?
If I try to insert a column with IBOconsole with the table editor it
says that there needs to be a value in the auto-increment field.
Doing a manual insert also produces an error too..
I bought the "The Firebird Book" today and overall it has been great
but I have not found any resolution to the problem that I stated
above.
thanks!
Firebird accepts the trigger without barfing..
However, it doesn't seem to be working.
If I insert a column, the auto-increment trigger should magically
work, right?
If I try to insert a column with IBOconsole with the table editor it
says that there needs to be a value in the auto-increment field.
Doing a manual insert also produces an error too..
I bought the "The Firebird Book" today and overall it has been great
but I have not found any resolution to the problem that I stated
above.
thanks!
> The following script works for me (tested in IBOConsole), there area few
> changes from what you posted (look at set term and NEW.ITEMNUM =GEN_ID...)
>Generator had
> CREATE TABLE ITEMS (
> ITEMNUM INTEGER NOT NULL,
> CATEGORYNUM INTEGER,
> PRIMARY KEY (ITEMNUM)
> );
>
> CREATE GENERATOR ITEMNUM_ID;
>
> COMMIT;
>
> SET TERM ## ;
>
> CREATE TRIGGER ITEM_ID_TRIG FOR ITEMS
> BEFORE INSERT POSITION 0 AS
> BEGIN
> NEW.ITEMNUM = GEN_ID(ITEMNUM_ID, 1);
> END ##
>
> SET TERM ; ##
>
> COMMIT;
>
> The error you were receiving was more than likely because the
> already been created (presuming you ran this script more than once)question...
>
> Hih
>
> Si Carter
> http://www.tectsoft.net/
>
>
> > -----Original Message-----
> > From: cowmix3 [mailto:mmarch@g...]
> > Sent: 04 March 2005 10:51
> > To: firebird-support@yahoogroups.com
> > Subject: [firebird-support] Arg.. Autonum generator newbie
> >transactions) in
> >
> >
> > I have looked at every example and I can't get things to
> > work.. Here is what I have for my example:
> >
> > CREATE TABLE "ITEMS"
> > (
> > "ITEMNUM" INTEGER NOT NULL,
> > "CATEGORYNUM" INTEGER,
> > PRIMARY KEY ("ITEMNUM")
> > );
> >
> >
> >
> >
> > CREATE GENERATOR ITEMNUM_ID;
> > COMMIT;
> > SET TERM;
> >
> > CREATE TRIGGER ITEM_ID_TRIG FOR ITEMS
> >
> > BEFORE INSERT POSITION 0
> > AS BEGIN
> > ITEMS.ITEMNUM = GEN_ID(ITEMNUM_ID, 1);
> > END
> >
> > SET TERM ;
> >
> > And I get something like this:
> >
> > ISC ERROR CODE:335544351
> >
> > ISC ERROR MESSAGE:
> > unsuccessful metadata update
> > DEFINE GENERATOR failed
> > attempt to store duplicate value (visible to active
> >
> > unique index "RDB$INDEX_11"
> >
> > Arg!
> >
> > Help!
> >
> > <march>
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >