Re: newbe insert question
Posted in 1994
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL
Matthew:
This is what you would do:
Before you insert into the serial field, you have to set the value to
be inserted into this field to be a zero. Right after the insert
statement and after you check for a successful execution of your insert
statement, the value of the serial field for the new inserted row is
stored in an Informix defined variable called sqlca.sqlerrd[2].
Example of 4GL code:
let some_serial = 0
insert into some_table values (some_serial)
{Check for successful execution of insert and get the new serial value}
if status = 0 then
let new_serial = sqlca.sqlerrd[2]
end if
Note: If you do not check for successful execution of your insert statement
the same field sqlca.sqlerrd[2] may contain an ISAM error code if
your insert statement fails for whatever reason.
More detail on this can be found in the Informix manual in the section
where the syntax of the INSERT statement is discussed.
----
Regards,
Francis Chue
Unix System Project Leader
American TriTech Internet: fsc0@tritech.com
10717 Sorrento Valley Road Voice : (619)453-7000 ext. 283
San Diego, CA 92121 Fax : (619)453-8709