Re[2]: Get key of row just inserted?
Posted in 1998
Topics: Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Triggers, Constraints & Referential Integrity, Jobs, Consulting & Announcements
Note: Some recipients have been dropped due to syntax errors.
Please refer to the "$AdditionalHeaders" item for the complete headers.
Or how about using the SQLCA record ?
SQLCA.SQLERRD[2] (in 4gl)
SQLCA.SQLERRD[1] (in esql/c)
Will return the value of the serial just inserted (Assuming that
SQLCA.SQLCODE is flagged as successful)
Regards.
Stuart Knight.
______________________________ Reply Separator ____________________________
_____
Subject: Re: Get key of row just inserted?
Author: Glyn_Balmer_at_erith@smtpgwy.supertension.com at LEND LEASE/LLAP
Date: 25/02/98 10:10
flint weiss wrote :-
> hello all,
> i have a table using SERIAL keys.
> i want to insert a new row and then get the 'new' key of that
row.
> is there a way to find the key of the row just inserted?
> thanx,
> flint weiss
Dependent upon the version of the engine you are running, you
could
create a trigger that detects an insertion on the relevant
table, then
carry out whatever action you require armed with the inserted
row,
e.g :-
-- tr_tab_ins.sql
-- drop trigger tr_tab_ins;
create trigger tr_tab_ins insert on tab
referencing new as inserted
for each row
(action)
As far as I am aware, triggers became available in version 5.01of the
engine. See Informix Guide to SQL Syntax v6.0 (Informix Part
No.
000-7597).
Regards
Glyn Balmer
I.T. Consultant
BICC Cables Limited
Erith Kent UK
glynb@bicceri.demon.co.uk