Re: [INTERFACES] locking on database updates - Mailing list pgsql-interfaces

From Douglas Thomson
Subject Re: [INTERFACES] locking on database updates
Date
Msg-id 199912080434.PAA31285@mugca.cc.monash.edu.au
Whole thread Raw
In response to RE: [INTERFACES] locking on database updates  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-interfaces
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.

pgsql-interfaces by date:

Previous
From: Joseph Shraibman
Date:
Subject: sql question
Next
From: Tom Lane
Date:
Subject: Re: [INTERFACES] sql question