http://manas8x/BareBone_PHP/nested_cursor1/nested_cursor2.php
Script:
<?php
// Connects to the XE service (i.e. database) on the "localhost"
machine
$conn = oci_connect('scott', 'Son', 'localhost/orcl.gateway.2wire.net');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
echo" DB connected: querying a table <br/>";
$sql ='select dname,
cursor(select ename, job
from emp
where emp.deptno = dept.deptno) as
nc
from dept
where deptno in (10, 20, 30)';
$s = oci_parse($conn, $sql);
$r = oci_execute($s);
while (($row1 = oci_fetch_array($s, OCI_ASSOC)) != false) {
echo "Department: " . $row1['DNAME'] . "<br>\n";
$nc = $row1['NC']; // treat as a statement resource
oci_execute($nc);
while (($row2 = oci_fetch_array($nc, OCI_ASSOC+OCI_RETURN_NULLS)) !=
false) {
echo "ename : ". $row2['ENAME'] . "   job :".$row2['JOB'] . "<br>\n";
}
oci_free_statement($nc);
echo "<br>\n";
}
?>