Hello people, Thanks for all your help. I guess I'll go with $oid = pg_last_oid($result); select id from table where oid = $oid;
If i'm not mistaken, there will no race issue here: pg_last_oid($result) has already returned me the row that 'I' have just inserted, based on $result, regardless whether there is another user doing an insert. I already have a reference to a row i just inserted. On the other hand, BEGIN INSERT ... whatever SELECT idno ORDER BY (idno) DESC LIMIT 1; END; will have some 'time' between the 'insert' and the 'select'. There is no reference to a row based on $result. There would still probably be a race issue here (just my opinion, not a fact). But if there's anyone could explain the internals, I'd be glad. Thanks for all who helped. Sincerely, Faisal -----Original Message----- From: Leonid Mamtchenkov [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 19, 2002 5:35 AM To: Faisal Abdullah Cc: Marek Kilimajer; PHP Subject: Re: [PHP] Auto-increment value Dear Faisal Abdullah, Once you wrote about "RE: [PHP] Auto-increment value": > > There is a similar one for postgresql as well: pg_last_oid() . > > I tried that. It gives me 24807, instead of 5. > Or is oid is a reference to something else, which would > lead me to the '5' i'm looking for? I'd bet that 24807 is your oid. Check the difference between "SELECT * FROM table;" and "SELECT oid,* FROM table;". HTH. > -- snip snip -- > > if($result = pg_exec($db, $sql)) > { > $query = "success"; > echo "oid : " .pg_last_oid($result); > } > > -- snip snip -- -- Best regards, Leonid Mamtchenkov, RHCE System Administrator Francoudi & Stephanou Ltd. BOFH: somebody was calculating pi on the server ______________________________________ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php