I need to insert a record into a table and set the value of a column (e.g. orderid) to a unique #. And return that number used.
I thought the process would be to do use a sequence and an insert statement with nextval:
insert into ordersTable(orderid) values(ordernums.nextval);
But how to I get the number that was used? My thought is that I have to get it back from the insert call otherwise the nextval (or currval) could have changed if I re-query.
But I'm not sure how to do that. One way around this I thought would be to, on insert, also add my only unique value to a field, then requery for that value.
Is there another way to do this? I figure I probably missing something at the sql level?
CtC