RE: [PHP] Oracle query with one returned record

From: Date: Mon, 15 Oct 2001 14:11:35 +0000
Subject: RE: [PHP] Oracle query with one returned record
Groups: php.general 
Request: Send a blank email to php-general+get-71104@lists.php.net to get a copy of this message
if (!OCIFetchInto($curs,$data))) { // not found } else { $companyname = $data[0]; $companyaddress = $data[1]; $companyaddress2 = $data[2]; $companycity = $data[3]; $companystate = ucwords($data[4]); $companypostalcode = $data[5]; $companycountry = ucwords($data[6]); } -----Original Message----- From: J. Anderson Scarbrough [mailto:jebscarbrough@hotmail.com] Sent: 15 October 2001 14:57 To: php-general@lists.php.net Subject: [PHP] Oracle query with one returned record When I have an oracle procedure that returns one and only one row i still find myself looping through the cursor to get the results. is there a better way to accomplish this without writing a loop when you know the loop will only execute once? (code below) Thanks. query = "begin pkg.procedure($id, :curs, :errorCode); end;"; //query should return only the details of the $id passed in to proc. $curs = OCINewCursor($connection); $stmt = OCIParse ($connection, $query); OCIBindByName ( $stmt, ":curs", &$curs,-1,OCI_B_CURSOR); OCIBindByName ($stmt, ":errorCode", &$errorCode,10); $result = OCIExecute ($stmt); $result = OCIExecute ($curs); while (OCIFetchInto($curs,$data)) { $companyname = $data[0]; $companyaddress = $data[1]; $companyaddress2 = $data[2]; $companycity = $data[3]; $companystate = ucwords($data[4]); $companypostalcode = $data[5]; $companycountry = ucwords($data[6]); } OCIFreeStatement($stmt); OCIFreeCursor($curs); ?> _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#71104) next »