Reidy, Ron [mailto:[EMAIL PROTECTED] wrote:


> Am I right to think that the following is nearly as efficient as a
> trigger-based approach?
>       insert into customer(customer_id, first, last)
>       values(customer_id_seq.nextval, 'Homer', 'Simpson');
> 
>       insert into address(address_id, customer_id, street, town)
>       values(address_id_seq.nextval, customer_id_seq.currval, '742
> Evergreen Tr.', 'Springfield');
> 
> [rr] This will not work.  What happens when there are multiple processes
> running an insert into customer at the same time.  Sequences are not
> transactional.

I believe you are mistaken.  sequence.CurrVal would not be very useful if
you weren't guaranteed to get the current value from your own session.

I just tested this with two sqlplus sessions, and the first session returned
the correct value with CurrVal even after selecting NextVal from the second
session, exactly as I would have expected.

Ronald


Reply via email to