Re: sequence integrity insite begin-commit?

From: Rob Brown-Bayliss <rob(at)ZOOstation(dot)cc>
To: PGSQL Novice List <pgsql-novice(at)postgresql(dot)org>, Python <python-list(at)python(dot)org>
Subject: Re: sequence integrity insite begin-commit?
Date: 2001-05-23 22:17:14
Message-ID: 990656235.1454.0.camel@ZOOstation.cc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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======---
> www.ZOOstation.cc

--

Rob Brown-Bayliss
---======o======---
www.ZOOstation.cc

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2001-05-23 22:45:56 Re: Re: sequence integrity insite begin-commit?
Previous Message Rob Brown-Bayliss 2001-05-23 21:57:27 IGNORE-Mail relay test