1
2 <?php
3 print "<HTML><BODY>";
4 $conn = OCILogon("scott","tiger");
5 $count_cursor = "CURSOR(select count(empno) num_emps from emp " .
6 "where emp.deptno = dept.deptno) as EMPCNT from dept";
7 $stmt = OCIParse($conn,"select deptno,dname,$count_cursor");
8
9 ociexecute($stmt);
10 print "<TABLE BORDER=\"1\">";
11 print "<TR>";
12 print "<TH>DEPT NAME</TH>";
13 print "<TH>DEPT #</TH>";
14 print "<TH># EMPLOYEES</TH>";
15 print "</TR>";
16
17 while (OCIFetchInto($stmt,&$data,OCI_ASSOC)) {
18 print "<TR>";
19 $dname = $data["DNAME"];
20 $deptno = $data["DEPTNO"];
21 print "<TD>$dname</TD>";
22 print "<TD>$deptno</TD>";
23 ociexecute($data[ "EMPCNT" ]);
24 while (OCIFetchInto($data[ "EMPCNT" ],&$subdata,OCI_ASSOC)) {
25 $num_emps = $subdata["NUM_EMPS"];
26 print "<TD>$num_emps</TD>";
27 }
28 print "</TR>";
29 }
30 print "</TABLE>";
31 print "</BODY></HTML>";
32 OCIFreeStatement($stmt);
33 OCILogoff($conn);
34 ?> |