Inserting a serial key with stored procedures
Posted in 1993
John Bossert — — source: Informix-list mailing list archive (1991-1998)
Yet another Stored Procedures question!
The serial type is not a valid datatype within stored procedure language
(SPL). How can one insert the "next highest value" into a serial field?
Suppose I have:
create table foo(foo_nr serial, foo_date date);
and I want to create an SP that, passed a date, would insert a row with
the desired date AND the next highest value of foo_nr as a key.
How should this be done?
I don't want to deal with a race issue where I query to get the max() value
of the key, and then scramble to insert before someone else beats me to it.
--
In-Real-Life: John Bossert, Thalatta Corporation, (+1 206.455.9838)
Domain: bossert@thalatta.com Path: ...!sun!sunup!thebes!bossert