Some packages in oracle are functions, and that functions returns a cursor.
For example:
CREATE FUNCTION F_Function( p1 char(2), p2 int)
RETURN SYS_REFCURSOR
AS
my_cursor SYS_REFCURSOR;
BEGIN
OPEN my_cursor FOR SELECT * FROM allitems
WHERE (cod=p1)
AND (Number=p2);
RETURN my_cursor;
END F_Function;
Here is the code that allows to obtain data from a function that returns a cursor.
<pre>
<?php
$conn=oci_connect("server", "user", "pass");
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message']), E_USER_ERROR);
}
$p1 = '03';
$p2 = 2012016191;
$stid = oci_parse($conn, 'begin :cursor := server.PKG_package.F_Function(:p1,:p2); end;');
$p_cursor = oci_new_cursor($conn);
oci_bind_by_name($stid, ':p1', $p1,2);
oci_bind_by_name($stid, ':p2', $p2,10);
oci_bind_by_name($stid, ':cursor', $p_cursor, -1, OCI_B_CURSOR);
oci_execute($stid);
oci_execute($p_cursor, OCI_DEFAULT);
oci_fetch_all($p_cursor, $cursor, null, null, OCI_FETCHSTATEMENT_BY_ROW);
echo '<br>';
print_r($cursor);
?>