All,

I have read the the various postings about using the MAX() function to
get the last value entered into the Primary Key field.
This will not do for me as you will see.
Plus I believe it is proned to errors.

I have a table that is defined as follows:
create table tbl ( pk number(11) not null primary key, name varchar2(20)
)

I have created a sequences as follows:
create sequence tbl_seq;

The table has a trigger on the PK column for autonumbering and it is
defined as follows:
create trigger tbl_autonumber before insert on tbl for each row
begin
 select tbl_seq.nextval into :NEW.pk from dual;
end;

After four people have inserted four seperate new records at the same
time, how can I find out the Primary Key that was assigned to my new
record?

Here is a possible solution that I was thinking about but not sure if it
is the optimal solution.
Add an additional column to the table and use it as a stamp.
When I insert the new record I would put a unique number into this
column so that I can find the record in my next SELECT query.

Ideally, I would like the INSERT statement to return the Primary Key
value to me.
Maybe an Oracle procedure or Oracle function would be the way to go.

Sincerely,
Troy

--
Troy Simpson | North Carolina State University
NCSU Libraries | Campus Box 7111 | Raleigh | North Carolina
ph.919.515.3855 | fax.919.513.3330

It is better to be hated for what you are
than to be loved for what you are not.
  -- Andre Gide

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to