Re: Get key of row just inserted?
Posted in 1998
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.01 of 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