sequence integrity insite begin-commit?

Rob Brown-Bayliss rob at
Wed May 23 18:17:14 EDT 2001

On 03 May 2001 01:00:14 +1200, Rob Brown-Bayliss wrote:
> Hi.  I am develeoping an app with python that uses postgresql.  
> I have hit a snag in that I need to know the value of a sequence from an
> insert just performed, but the interface from python to postgres (called
> PoPy) does not return the oid from the insert as psql does.
> So what I am doing is begining a transaction, inserting the data,
> selecting the last_value from the sequence and then commiting the
> transaction.
> I ma not sure if this will work in the real world as what happens if
> between one user inserting their data if another insets data as well?
> will the last_value from the sewuence (inside the transaction) be
> correct, or will it show the valu for the second user?
> Am I being clear? try this
>     USER ONE     |     USER TWO
>     ===========================
>     Begin        | Begin
>     Insert       | Insert
>     Select       | Select
>     Commit       | Commit
> If these two are happening at the same time (or as near as is possible
> can I rely on the selected last_value being the sequence value that was
> inserted by the user?  (the sequence is the default falue for a column
> and user does not enter it)
> Thanks
> -- 
>   Rob Brown-Bayliss
>  ---======o======---


  Rob Brown-Bayliss

More information about the Python-list mailing list