Oracle是否等效于SCOPE_IDENTITY()?

问题描述:

有人可以在这里验证我的想法吗?此代码是否返回我的语句插入的正确序列号:

Can some one verify my thinking here? Does this code return the correct Sequence Number as Inserted by my statement:

INSERT (myTablePrimaryKey, Field1, Field2)
VALUES (myTableSeqNo.NextVal, 'Data1', 'Data2')

Select myTableSeqNo.currval



这会返回我插入到表中的序列号吗?是否可以保证它在有许多用户和插入内容的繁忙环境中属于我?

谢谢.



Does this return the sequence number I inserted to the table and is it guaranteed to be mine in a busy environment with many users and inserts?

Thanks.

是的,因为oracle按会话记录了周期.除非有人同时使用您的会话.会一样.
Yes it does, as oracle records the currval by session. Unless someone is using your session at the same time. It will be the same.