Originally posted by Kris Reid:
Hi
Is there a way to get back in one query the auto inserted number for a query.
i.e.
At the moment I use 2 queries
INSERT INTO Blah (ID) VALUES (my_seq.NEXTVAL)
then:
select my_seq.currval from dual
Thanks
The only way I can think of to do it in one call is with a stored procedure.
However, if your goal is really to avoid the concurrency problems that the above approach has, you can merely shuffle things around a bit:
Each
thread will retrieve a unique value from the sequence and return it to your
Java code, where you can then do a normal insert.