Re: sql server -> informix
Posted in 2003
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 are correct, there is no way around it without giving the database
server a clue as to which columns to place those values in.
You can use this syntax:
INSERT INTO table_a (col2, col3) VALUES(field_2, field_3)
Incidentally, the serial value does default to zero, which allocates the
next number in sequence, but this requires changes to your code.
You can use a view as described by others, but you will still need to
change your code.
In short, you need to change your code for it to work. Migration between
database servers is never painless. You need to use something like awk,
which can do this sort of conversion for you.
Cheers,
--
Mark.
+----------------------------------------------------------+-----------+
| Mark D. Stock mailto:mdstock@MydasSolutions.com |//////// /|
| Mydas Solutions Ltd http://MydasSolutions.com |///// / //|
| +-----------------------------------+//// / ///|
| |We value your comments, which have |/// / ////|
| |been recorded and automatically |// / /////|
| |emailed back to us for our records.|/ ////////|
+----------------------+-----------------------------------+-----------+