| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Mike Nolan <nolan(at)gw(dot)tssi(dot)com> |
| Cc: | kleptog(at)svana(dot)org, db(at)zigo(dot)dhs(dot)org (Dennis Bjorklund), spinel(at)noos(dot)fr (Stephane Pinel), pgsql-general(at)postgresql(dot)org |
| Subject: | Re: GetLastInsertID ? |
| Date: | 2004-01-04 19:26:57 |
| Message-ID: | 1562.1073244417@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Mike Nolan <nolan(at)gw(dot)tssi(dot)com> writes:
>> Where do you get that impression? currval() refers to the last ID for the
>> session you are in. It's also FAQ question 4.15.3. Even better, if you
>> havn't used nextval() in your current session, currval() returns an error,
>> so you can't even get it wrong by accident.
> I stand corrected. I was doing some testing of a PHP module that is
> called from a web form a while back and got inconsistent results with
> currval, I probably had a script error of some kind.
If you are using persistent connections in PHP you have to be very
careful, because independent bits of PHP script may re-use the same
database connection, and thereby will see a common currval value.
After doing a nextval, you have to be sure to fetch currval before
releasing the connection back to the pool.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Sabino Mullane | 2004-01-04 19:40:32 | Re: website doc search is extremely SLOW |
| Previous Message | Alex J. Avriette | 2004-01-04 19:13:22 | Re: psql \d option list overloaded |