pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Douglas Thomson <dougt@mugc.cc.monash.edu.au>
To: gary.stainburn@ringways.co.uk
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] locking on database updates
Date: Wed, 8 Dec 1999 15:34:33 +1100 (EST)
Message-ID: <199912080434.PAA31285@mugca.cc.monash.edu.au> (raw)
In-Reply-To: <01BF40D0.F4BA79A0@garys.ringways.co.uk>

Gary Stainburn writes:
> I agree that using a type 'serial' will give me what I want
> regarding the key field for my table, and gets round the problem
> of concurrent users trying to create records with the same number.
>
> The problem is that this does not actually give me the number that
> was just created.  As there is no guarantee that the other fields in
> the table are unique (hence the serial field in the first place) I cannot
> simply do a select to retrieve it.
>
> Has anyone any ideas?

For what it is worth, I saved the OID returned by the INSERT (see
PQoidStatus - the details depend on what interface language you use),
and then selected the row I had just inserted using:
    SELECT id FROM name_map WHERE oid=12345

Doug.



view thread (21+ messages)  latest in thread

Message-ID: <199912080434.PAA31285@mugca.cc.monash.edu.au>
Permalink:  ../199912080434.PAA31285@mugca.cc.monash.edu.au/
Also on:    postgresql.org/message-id/199912080434.PAA31285@mugca.cc.monash.edu.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: dougt@mugc.cc.monash.edu.au, gary.stainburn@ringways.co.uk
  Subject: Re: [INTERFACES] locking on database updates
  In-Reply-To: <199912080434.PAA31285@mugca.cc.monash.edu.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox