Oracle Stored Procedure Ref Cursor

admin

Administrator
Staff member
I have been testing with returning a ref cursor from an oracle stored procedure to PHP. I am getting the error:
Warning: OCIStmtExecute: ORA-24370: illegal piecewise operation attempted in f:\websites\testoracle3.php on line 14
any help is appreciated
Below is the package, procedure and php code:
PACKAGE:
AS
-- Define a ref cursor datatype
TYPE REFCURSOR IS REF CURSOR;
END PHP_CURSOR;
PROCEDURE:

(
RC IN OUT PHP_CURSOR.REFCURSOR
)
IS
BEGIN
OPEN RC
FOR SELECT username
FROM all_users
;
END PHP_TEST;
PHP CODE:
<?php

//Calling Login Values.. we keep the DB Login Info in a single file
$db_id = ocilogon("user", "pass", "db");

//Create Query String
$queryStr = "begin PHP_TEST(:myCurs); end;";

$cursor = OCINewCursor($db_id);
$stmt = OCIParse ($db_id, $queryStr);

//Bind the returned cursor
OCIBindByName($stmt, "myCurs", &$cursor, -1, OCI_B_CURSOR);
OCIExecute($stmt);
OCIExecute($cursor);


//Find number of columns returned and initialize array to accept data
$numOfColls = OCINumCols($cursor);
$result = array();
$arr_index = 0;

//This will step thru the data returned in the cursor
while(OCIFetch($cursor))
{
// Iterate thru the number of columns in the returned data
// creating an ASSOC 2D-array
for ($i=1; $i<=$numOfColls; $i++)
{
$colName = OCIColumnName($cursor, $i);
$result[$arr_index][$colName] = OCIResult($cursor,$colName);
echo "$colName = $result[$arr_index][$colName]\n";
}

// Increment the numeric value of the ASSOC array
$arr_index = $arr_index+1;

} // End While

OCILogoff($db_id);
?>
 
Back
Top