From: Ross J. Reedstrom <reedstrm@wallace.ece.rice.edu>
To: Gary Stainburn <gary.stainburn@ringways.co.uk>
Cc: 'Pgsql Interfaces' <pgsql-interfaces@postgresql.org>
Subject: Re: [INTERFACES] locking on database updates
Date: Tue, 7 Dec 1999 11:12:34 -0600
Message-ID: <19991207111234.A6021@rice.edu> (raw)
In-Reply-To: <01BF40D0.F4BA79A0@garys.ringways.co.uk>
References: <01BF40D0.F4BA79A0@garys.ringways.co.uk>
On Tue, Dec 07, 1999 at 04:34:37PM -0000, Gary Stainburn wrote:
> Hi all,
>
> I've just read the last message I sent and apologise for the poor English.
> Let me put it a little clearer.
>
> 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?
create table foo (bar serial, baz text);
insert into foo (baz) values ('wooble');
select currval('foo_bar_seq');
>
> Thanks,
>
> Gary
you're welcome ;-)
Ross
--
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu>
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St., Houston, TX 77005
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: reedstrm@wallace.ece.rice.edu, gary.stainburn@ringways.co.uk
Subject: Re: [INTERFACES] locking on database updates
In-Reply-To: <19991207111234.A6021@rice.edu>
* 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