Re: Sequence Numbers - Can you read them synchronously?

From: Saad Ahmad <sahmad_at_mfa.com>
Date: 1995/04/03
Message-ID: <3lp082$1pf_at_homer.alpha.net>#1/1


Suresh B Peram (peram_at_cs.tamu.edu) wrote:
> We have multiple processes trying to insert rows into a table.
> One of the columns is a sequence number. Insertions are being
> done using stored procedures. The sequence number is the only
> primary key to the table.
> When I insert a rows into the table, I do a 'nextval' on the
> sequence number. At this time, I would like to get the value
> of the sequence number back for use in another table. But, I am
> afraid that some other process could be updating the table at the
> same time. This means that I would not be able to use 'currval' after
> I do a 'nextval' because the sequence number could be updated in between.
> How should I address this problem?

2 ways

  1. x = seq.nextval use x in as many tables as you want.
  2. I think seq.curval gives YOUR seq.curval, so if someone else inserts after that it should not change for you.
--
**************************************************************
*                          Saad Ahmad                        *
*                          E-Mail: sahmad_at_mfa.com            *
**************************************************************
Received on Mon Apr 03 1995 - 00:00:00 CEST

Original text of this message