Subject | Re: [firebird-support] insert statement |
---|---|
Author | Martijn Tonies |
Post date | 2004-08-25T15:46:37Z |
Hi,
fields. What you have is a _pseudo_ auto-increment field.
You can ommit any fields that:
- are defined as NULLable
- get filled by triggers
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com
> for some reason I expected this won't work, but I'd like to hearInsert what?
> 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 what?
> insert into obiekty; <- that would be particulary niceInsert what?
> the statementThere's no auto-increment field. Firebird doesn't support auto-increment
> 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?
fields. What you have is a _pseudo_ auto-increment field.
You can ommit any fields that:
- are defined as NULLable
- get filled by triggers
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com