Re: Squence Number
Posted in 2000
If I understand your question correctly, you want a unique identifying number
for a table. If that is the case, you would need a field with a data type of
SERIAL in your table. When you insert a record into the table, the database
generates a unique number to populate that field.
The following is taken from a posting from last week:
[Informix provides several mechanisms for retrieving the generated serial
value following an insert:
1) If you are using ESQL/C, the serial number assigned to the record is made
available via the sqlca.sqlerrd[1] field. This is documented in the
Informix-ESQL/C Programmer's Manual in Chapter 8.
2) If you use the ODBC API, the following function will retrieve the serial
value if called immediately following the insertion:
rc = SQLGetStmtAttr(hstmt_, SQL_GET_SERIAL_VALUE, &serial,
SQL_IS_INTEGER, NULL);
3) The following query will also do the trick:
SELECT UNIQUE DBINFO("sqlca.sqlerrd1") FROM systables WHERE tabid=1;
Hope this helps!
...Jake]
Hope this helps,
Sue
pchapp@sapient.com on 02/06/2000 12:19:21
Please respond to pchapp@sapient.com
To: informix-list@iiug.org
cc: (bcc: Sue Davidson/EXE)
Subject: Squence Number
Hi,
I am very new to informix. I have come from Oracle world. Is
there any way we can create sequence in infromix and used it for the id
(for example user_id). Please help me.
Thank you very much.
Prabha
Sent via Deja.com http://www.deja.com/
Before you buy.