RE: [PHP] Oracle query with one returned record

From: Date: Mon, 15 Oct 2001 13:52:21 +0000
Subject: RE: [PHP] Oracle query with one returned record
Groups: php.general 
Request: Send a blank email to php-general+get-71102@lists.php.net to get a copy of this message
this was the first search result on google for +oracle +php +fetch +row check out ___Ora_Fetch___ hope it helps Dave LX. Oracle functions Table of Contents Ora_Bind - bind a PHP variable to an Oracle parameter Ora_Close - close an Oracle cursor Ora_ColumnName - get name of Oracle result column Ora_ColumnSize - get size of Oracle result column Ora_ColumnType - get type of Oracle result column Ora_Commit - commit an Oracle transaction Ora_CommitOff - disable automatic commit Ora_CommitOn - enable automatic commit Ora_Do - Parse, Exec, Fetch Ora_Error - get Oracle error message Ora_ErrorCode - get Oracle error code Ora_Exec - execute parsed statement on an Oracle cursor Ora_Fetch - fetch a row of data from a cursor Ora_Fetch_Into - Fetch a row into the specified result array Ora_GetColumn - get data from a fetched column Ora_Logoff - close an Oracle connection Ora_Logon - open an Oracle connection Ora_pLogon - Open a persistent Oracle connection Ora_Numcols - Returns the number of columns Ora_Numrows - Returns the number of rows Ora_Open - open an Oracle cursor Ora_Parse - parse an SQL statement Ora_Rollback - roll back transaction -----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 (#71102) next »