RE: [PHP] Auto-increment value

From: Date: Wed, 18 Sep 2002 11:31:55 +0000
Subject: RE: [PHP] Auto-increment value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116719@lists.php.net to get a copy of this message
Would a "select last_value from sequence_name" do any good? Is there a possibility that I get a value from the outcome of a nextval by another session? Meaning, I do an insert 1, 2, 3, 4 A 'select last_value from sequence_name' should give me '4'. But what if another user/session does another insert/nextval(), before my select statement finishes processing? Would I get a 5? Sincerely, Faisal -----Original Message----- From: Faisal Abdullah [mailto:faisal@magnifix.com.my] Sent: Wednesday, September 18, 2002 6:37 PM To: PHP Subject: RE: [PHP] Auto-increment value 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? -- snip snip -- if($result = pg_exec($db, $sql)) { $query = "success"; echo "oid : " .pg_last_oid($result); } -- snip snip -- Sincerely, Faisal -----Original Message----- From: Marek Kilimajer [mailto:kilimajer@webglobe.sk] Sent: Wednesday, September 18, 2002 5:42 PM To: PHP Subject: Re: [PHP] Auto-increment value As he uses postgresql, he should use *pg_last_oid()* Scott Houseman wrote: > Hi there. > > You can use the function mysql_insert_id( [link id] ). > > regards > > Scott > > Faisal Abdullah wrote: > >> Hi people, >> >> I have a table with a column called ID (auto-increment). >> Is it possible to know the value of ID, right after inserting a row? >> I'm using postgresql. >> >> Thanks. >> >> Sincerely, >> Faisal >> >> ______________________________________ >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ______________________________________ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php ______________________________________

« previous php.general (#116719) next »