pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: GB Clark <postgres@vsservices.com>
To: friedrich nietzsche <nietzsche_psql@yahoo.it>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-general@postgresql.org
Subject: Re: [SQL] Retrieving the new "nextval" for primary keys....
Date: Mon, 2 Sep 2002 14:50:33 -0500
Message-ID: <20020902145033.4a621385.postgres@vsservices.com> (raw)
In-Reply-To: <20020828163610.70353.qmail@web12907.mail.yahoo.com>
References: <3D6CF5B7.90206@nurseamerica.net>
	<20020828163610.70353.qmail@web12907.mail.yahoo.com>

On Wed, 28 Aug 2002 18:36:10 +0200 (CEST)
friedrich nietzsche <nietzsche_psql@yahoo.it> wrote:

>  One solution seems to locking table(s),
> but I prefer to leave it as last chance...
> using table locks, and the trick of writing and
> suddenly reading back from DB it probably works,
> but it doesn't seems so sexy... :)
> ciao
> danilo 
> 

Why would you have to lock the table?  currval() is connection safe.

I would either do the insert and then do a currval() OR do a nextval()
and do the insert.  Either one would work. I always just do the insert
and then call currval() to get the current serial number for the connection.

GB

-- 
GB Clark II             | Roaming FreeBSD Admin
gclarkii@VSServices.COM | General Geek 
           CTHULU for President - Why choose the lesser of two evils?



view thread (4+ messages)

Message-ID: <20020902145033.4a621385.postgres@vsservices.com>
Permalink:  ../20020902145033.4a621385.postgres@vsservices.com/
Also on:    postgresql.org/message-id/20020902145033.4a621385.postgres@vsservices.com

 · 

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-sql@postgresql.org
  Cc: postgres@vsservices.com, nietzsche_psql@yahoo.it, pgsql-general@postgresql.org
  Subject: Re: [SQL] Retrieving the new "nextval" for primary keys....
  In-Reply-To: <20020902145033.4a621385.postgres@vsservices.com>

* 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