Posted in 2003
On Wed, 11 Jun 2003 09:41:31 -0400, rkusenet wrote:
> We are about to port an application from SQL Server to Informix. In SQL
> Server, identity column (equivalent of serial) is always the first
> column. This gives the developers an advantage of skipping the first
> column (if it is identity) and SQL server will automatically assign the
> next higher number during an insert.
>
> So we have inserts like
> insert into table_a values(field_2,field_3).>
> In this case field_1 is an identity field and gets value automatically.
>
> Can this code work in Informix. Is there a way around, though I don't
> think so.
You will have to make one change. You have to add a column list for the
fields you will be inserting to. You CAN leave out the serial column
altogether and the values will be assigned correctly but the number of
columns in the VALUES clause and the column list MUST match and an insert
without a column list is equivalent to a column list containing ALL
columns in the order they appear in the schema. So just change the
insert to:
insert into table_a (col_2, col_3) values (field_2_val, field_3_val);
Art S. Kagel
We use strictly necessary cookies to make this site work. With your consent we’d also use optional cookies for analytics and marketing. You can accept all, reject all, or choose. Read our Cookie Policy.