sql server -> informix
Posted in 2003
Topics: General Discussion
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.
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.
>
>
>
>
In your example create a view on the table omitting the identity
(serial) column. Then you can insert into the view:
create view table_a_v as select field_2, field_3 from table_a;
insert into table_a_v values ('blah', 'blah');
select * from table_a;
You will see the serial column has been filled in. This would only work
for the inserts; to get the serial value you can use the sql:
select DBINFO( 'sqlca.sqlerrd1' ) from systables where tabid = 1;
or query your sqlca structure.
Look into the "serial" data type.
"rkusenet" <rkusenet@sympatico.ca> wrote in message
news:bc7bl5$g757h$1@ID-75254.news.dfncis.de...
> 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.
>
>
>
>
>