Re: [PHP3] MySQL <-> Oracle8

From: Date: Wed, 07 Jun 2000 04:26:50 +0000
Subject: Re: [PHP3] MySQL <-> Oracle8
Groups: php.general 
Request: Send a blank email to php-general+get-1157@lists.php.net to get a copy of this message
Neither of these proposed solutions can guarantee you get the ID for the row you just inserted-- it's possible that another insert into the same table could occur before you select the ID (or the sequence value). What you need to do is this: <? $sSQL = "INSERT INTO your_table "; $sSQL .= "(name, field) "; $sSQL .= "VALUES ('test', 123) "; $sSQL .= "RETURNING id INTO :NEWID"; $nStmt = ociparse($nConn, $sSQL); ocibindbyname($nStmt, ":NEWID", &$nNewID, 10240); ociexecute($nStmt, "OCI_DEFAULT"); ?> Where "id" is the auto-number field in "your_table". When this code executes, $nNewID will hold the value of "id" for the row you just inserted. See ya, JRB LeagueOffice.com Fantasy Sports ------------------------------------------ http://www.leagueoffice.com as cool as fantasy sports get... ------------------------------------------ "Meir Kriheli - MKsoft" wrote: > > Do this query: > > > Select <your_sequence_name>.currval from dual; > > this will return the current value of the sequence. > > BTW if you replace currval with nextval you can cause the sequence > to increment and the result will be the incremented value. > > Hope that helps > Meir Kriheli > MKsoft computer systems > > ----- Original Message ----- > From: "Adam Powell" <adam@powlex.com> > To: "Dieter Kneffel" <data@wap4.com>; "php-general" > <php-general@lists.php.net>; <php3@lists.php.net> > Sent: Tuesday, June 06, 2000 4:30 AM > Subject: Re: [PHP3] MySQL <-> Oracle8 > > > > > > Try doing a MAX(ROW_ID) select, and using this as your ID... it will give > > you the highest ID in the table which is a good replacement. > > > > Thanks, > > Adam > > > > ----- Original Message ----- > > From: Dieter Kneffel <data@wap4.com> > > To: php-general <php-general@lists.php.net>; <php3@lists.php.net> > > Sent: Sunday, June 04, 2000 5:39 PM > > Subject: [PHP3] MySQL <-> Oracle8 > > > > > > > I need to get the ID generated from a previous INSERT operation. > > > > > > Is there an equivalent PHP/Oracle8 function for 'mysql_insert_id()' > > > using MySQL? > > > If not, how can I make a simple workaround? > > > > > > > > > Tnx, > > > > > > Dieter

« previous php.general (#1157) next »