Subject | Re: [firebird-support] insert statement |
---|---|
Author | Helen Borrie |
Post date | 2004-08-25T15:42:37Z |
At 03:37 PM 25/08/2004 +0000, you wrote:
./heLen
>for some reason I expected this won't work, but I'd like to hearYes, that's the idea of them.
>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?
./heLen