Re: Getting NEXTVAL just prior to a COMMIT

From: Staffan Persson <staffan.persson_at_sesv.mail.abb.se>
Date: 1995/09/14
Message-ID: <4399mv$990_at_sdaw04.seinf.abb.se>#1/1


In article <42qn25$fm6_at_its.hooked.net>, caharper_at_hooked.net says...
>
>We are looking for suggestions on how to assign an ID number based on the
>NEXTVAL of a sequence generator, after all the other fields of the table
>have been filled in.
>

One way to not loose any numbers is to _first_ commit the form without the ID, update the row with a database trigger, and then reread the form.
I suppose you can't use the ID number as a primary key if you use this method. But I'm not a guru so try it... :-)

Trigger:
create or replace trigger the_trigger after insert on the_table for each row
begin
  the_field := the_sequence.NEXTVAL;
end;

The_sequence should be created with ORDER.

Hope it helps,

-- 
 /*** staffan.persson_at_sesev.mail.abb.com ***\
/**** stpe_at_secrc.abb.se (if sesev fails) ****\
Received on Thu Sep 14 1995 - 00:00:00 CEST

Original text of this message