Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Guaranteed increasing timestamps?

user1391685Oct 22 2014 — edited Oct 24 2014

Say I do two insert transactions. Each of them is potentially inserting a large number of rows into a table. (These are actually done from a trigger, if it matters - the table is an audit log.)

I need to be able to guarantee that something - whether primary key, timestamp, etc - will be monotonically increasing. That is, I want something to be able to distinguish between the first insert transaction and the second one. The values don't necessarily have to be the same in all inserted rows within a single transaction - though that would be nice. All I need is to be able to guarantee that all the values I read for the second transaction to commit are greater than any value for the first transaction.

It seems like what I would really like is the value used for multiversioning concurrency. So, I thought that maybe I could use the ORA_ROWSCN. But in my experimentation shows that this value is a smallish number; in fact, it looks equivalent to seconds since the Unix epoch; converted to a timestamp with scn_to_timestamp it shows only second precision.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2014
Added on Oct 22 2014
23 comments
5,823 views