Subject Re: [firebird-support] insert statement
Author Helen Borrie
At 03:37 PM 25/08/2004 +0000, you wrote:

>for some reason I expected this won't work, but I'd like to hear
>your opinion
>
>I have a table that is a linking table in a many-to-many relation
>
>all it is needed there is an unique id so I created a table (along
>with generator and trigger)
>
>CREATE GENERATOR GEN_OBIEKTY_ID;
>CREATE TABLE OBIEKTY (
> ID INTEGER NOT NULL
>);
>/* Primary Key: PK_OBIEKTY */
>ALTER TABLE OBIEKTY ADD CONSTRAINT PK_OBIEKTY PRIMARY KEY (ID);
>/* Trigger: OBIEKTY_BI */
>CREATE TRIGGER OBIEKTY_BI FOR OBIEKTY
>ACTIVE BEFORE INSERT POSITION 0
>AS
>BEGIN
> IF (NEW.ID IS NULL) THEN
> NEW.ID = GEN_ID(GEN_OBIEKTY_ID,1);
>END
>
>I want to enter new record into this table so I tried all of the
>below:
>insert into obiekty () values ();
>insert into obiekty values;
>insert into obiekty; <- that would be particulary nice
>
>the statement
>insert into obiekty (id) values(null);
>worked, but on all other occassion I could skip the ID column
>
>what is suggested by SQL92 - can I ommit autoincremented fields in
>queries?

Yes, that's the idea of them.

./heLen