Re: Last inserted id - Mailing list pgsql-odbc

From David Horwitz
Subject Re: Last inserted id
Date
Msg-id 3BEF91F1.259781BC@ched.uct.ac.za
Whole thread Raw
In response to Re: Last inserted id  (Dave Page <dpage@vale-housing.co.uk>)
Responses Re: Last inserted id
List pgsql-odbc
Him

> Unless I'm missing something, option B _is_ multi-user safe.
> currval() doesn't return the "current" value of the sequence (like
> "select * from my_seq" would) -- it returns the last value that
> nextval() gave that session (hence, it isn't defined until that
> session does a nextval()).
>

Actually the issue is b) is multi-user safe
*if*  you have an exclusive lock on the table. If you don't it is quite
possible for a user to insert an other record between your insertion and the
currval() call

David
--
****************************************************
David Horwitz                   University of Cape Town
IT Officer                      Private Bag
Multimedia Education Group      Rondebosch
            7701
dhorwitz@ched.uct.ac.za          SOUTH AFRICA
Tel:+27 21 650 3841              Fax:+27 21 650 5045
http://www.meg.uct.ac.za
PGP key: http://www.meg.uct.ac.za/dhorwitz/david_horwitz.acs
*************************************************



pgsql-odbc by date:

Previous
From: Dave Page
Date:
Subject: Re: Last inserted id
Next
From: Jean-Michel POURE
Date:
Subject: Re: Last inserted id