Re: Sequence curval

From: Yoram zilberberg <elric_dm_at_netvision.net.il>
Date: 1996/04/28
Message-ID: <NEWTNews.830753501.29855.elric_dm_at_dialup.netvision.net.il>#1/1


In Article<3180DA3B.2781E494_at_openmarket.com>, <chen_at_openmarket.com> write:
> Path: news.NetVision.net.il!psinntp!psinntp!psinntp!howland.reston.ans.net!newsfeed.internetmci.com!in2.uu.net!brighton.openmarket.com!news
> From: Shuzi Chen <chen_at_openmarket.com>
> Newsgroups: comp.databases.oracle
> Subject: Sequence curval
> Date: Fri, 26 Apr 1996 10:14:19 -0400
> Organization: OpenMarket, Inc.
> Lines: 22
> Message-ID: <3180DA3B.2781E494_at_openmarket.com>
> NNTP-Posting-Host: u4-197.openmarket.com
> Mime-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> X-Mailer: Mozilla 2.01 (X11; I; BSD/OS 2.0 i386)
> CC: chen
>
> Sequence vs. identity
> In the Sybase, you can use 'select _at__at_identity'
> to get the identity value used without requiring the transaction. When
> using a sequence we can do
> 'select sequence.curval from dual'
> (Does this require a transaction?, dual is a system table)
> to get the value used. Assume I have two processes;
>
> Process 1 Process 2
> --------- ---------
> insert record
> insert record
> select seq.curval from dual
> select seq.curval from dual
>
> If the second record is inserted before the first process 'select'. What
> curval I will get from procees 1?
>
>
> ----------------------------------------------------------------------
> Shuzi Chen
> chen_at_openmarket.com

to be more specifiec :
1. sequences are NOT part of the transaction, there is

   locking problems etc.
2. dual is just a dummy table, it's the same as selecting

   from sybase without and from defined in the select. 3. (which was said by others) you can only call curval

   after you've called nextval. nextval returns the next    value for you from the sequence and than you can check what that value WAS    using the curval, you can never get someone else's    sequence value.

hope it helped
Yoram Z. Received on Sun Apr 28 1996 - 00:00:00 CEST

Original text of this message