RE: sql server -> informix
Posted in 2003
Topics: General Discussion
Define the serial column with default 0. Then it will act the same way as
identity columns in SQLServer. You do not need to change your code.
MW
> -----Original Message-----
> From: owner-informix-list@iiug.org
> [mailto:owner-informix-list@iiug.org]On Behalf Of Arthur Groen
> Sent: Thursday, 12 June 2003 3:15 a.m.
> To: rkusenet; informix-list@iiug.org
> Subject: Re: sql server -> informix
>
>
> Insert a 0 (zero) for the serial value and informix will
> asign the next
> serail the it.
>
> insert into table_a values(0, field_2,field_3).>
> You can read the value back with
> Let F_serail = SQLCA.SQLERRD[2]
>
>
> /Arthur
>
> ----- Original Message -----
> From: rkusenet <rkusenet@sympatico.ca>
> To: <informix-list@iiug.org>
> Sent: Wednesday, June 11, 2003 3:41 PM
> Subject: sql server -> informix
>
>
> > 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.
> >
> >
> >
> >
> >
>
"Murray Wood" <murray@quanta.co.nz> wrote in message news:bc860j$dh4$1@terabinaries.xmission.com...
>
> Define the serial column with default 0. Then it will act the same way as
> identity columns in SQLServer. You do not need to change your code.
NO.
An indentify in SQL Server can be omitted in the column names. In informix
it has to be mentioned.
For eg. if field1 is a serial fld (identity in SQL Server), and field2
to field5 are other fields.
In sql server I can write
insert into table values(field2,field3,field4,field5).
Note that field1 is not mentioned anywhere, neither in column list, nor
in values list. That's why SQL Server puts a restriction of having
identity column as the first column of the table.
If I do this in informix I will get
Number of columns in values do not match number of columns in table.
The problem is that in our code, field names has been omitted in insert.
Very SQL Server centric and even there it is not a good practice as
we can never add a new column in the table without breaking. Yeek!!!
"Murray Wood" <murray@quanta.co.nz> wrote in message news:bc860j$dh4$1@terabinaries.xmission.com... > > Define the serial column with default 0. serial column can not have a default 0. Error -593 is generated. I tried every way. There is no way in informix serial field can be left unmentioned in *both* column list and values list. In other words we have to change the code. Ravi