Re: [GENERAL] Retrieving PK of inserted row

2007-01-30 Thread Tom Lane
"woger151" <[EMAIL PROTECTED]> writes: > Reading around, I've seen the following methods discussed: > (1) Within a transation, do the INSERT, and then do a SELECT CURVAL > (2) Not necessarily within a transaction, get a candidate for the pk using > SELECT NEXTVAL, then INSERT the row. > (3) Use LA

Re: [GENERAL] Retrieving PK of inserted row

2007-01-30 Thread cedric
Le mardi 30 janvier 2007 12:19, woger151 a écrit : > (3) Use LASTVAL for this one : look at http://people.planetpostgresql.org/xzilla/index.php?/archives/169-Is-lastval-evil.html > > My questions: > * Are any of these methods flawed? > * Is there any reason to prefer (1) to (2)? > * I'm not sure w

[GENERAL] Retrieving PK of inserted row

2007-01-30 Thread woger151
I want to retrieve the primary key, which is a SERIAL, of a row I just inserted. In 8.2, I could use RETURNING, but I'm using 8.1. Reading around, I've seen the following methods discussed: (1) Within a transation, do the INSERT, and then do a SELECT CURVAL (2) Not necessarily within a transact