Just another followup.
It was too late last night when I wrote my last reply. The rowid solution of course would not work...
Quote:
With all due respect, this statement is not correct. Sequences are safe at a cursor level. If this were not true then the sequence generator provided in Hibernate would not work as it calls the specified sequence to get the nextval then applies that value to the insert. Using Oracle sequences in this manner is common. Of course it would be best to place the calls inside a transaction block too.
I stand corrected. I just tried a test with currval and it does understand the current-value partitioned by the connection (not cursor) such that selecting the currval psuedo column actually returns the last value returned for nextval *within that connection*.
Quote:
If this were not true then the sequence generator provided in Hibernate would not work as it calls the specified sequence to get the nextval then applies that value to the insert.
With all due respect, this statement is
not correct ;) Hibernate issues a "select seq_name.nextval from dual". It then retrieves that selected value from the resulting result set and uses that in the insert...
Anyway, yet another option would be to somehow utilize the oracle "insert into ... RETURNING column_list" syntax.