Skip site navigation (1) Skip section navigation (2)

Re: Last Id?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: me(at)alternize(dot)com
Cc: "Jan Danielsson" <jan(dot)danielsson(at)gmail(dot)com>,pgsql-novice(at)postgresql(dot)org
Subject: Re: Last Id?
Date: 2005-09-06 14:33:18
Message-ID: 17684.1126017198@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
<me(at)alternize(dot)com> writes:
> unfortunately as i had to find out some days ago, "session-local" is a bit 
> dependend on how (and when) you actually open up new db connections to the 
> db, especially when you maybe have connection pooling enabled.

If your connection pooler will flip the connection out from under you
within a transaction, you need another connection pooler.  If you are
doing the insert and then reading currval in separate transactions,
I'd suggest changing the logic to make it one transaction.  Whatever
you are going to do with the currval probably ought to be part of the
original inserting transaction anyway.

The nextval-then-insert approach is perfectly fine too of course,
but there's no reason you shouldn't be able to use currval.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Mike GDate: 2005-09-07 05:28:49
Subject: Re: howto to do an automated backup on windows xp?
Previous:From: Michael FuhrDate: 2005-09-06 13:16:23
Subject: Re: Inserting data in other db

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group