User's Manual
Using PL/SQL Ref Cursors to Return Result Sets
6-8 Oracle Database Express Edition 2 Day Plus PHP Developer Guide Beta Draft
if (!$r) {
$e = db_error($refcur, __FILE__, __LINE__);
return false;
}
return ($employeerecords);
}
The db_get_employees_rc() function executes the following anonymous
(unnamed) PL/SQL block:
BEGIN cv_types.get_employees($deptid, :rc); END;
The PL/SQL statement inside the "BEGIN END" block calls the stored PL/SQL
package procedure cv_types.et_employees(). This returns an
OCI_B_CURSOR ref cursor bind variable in the PHP variable $refcur.
The $refcur variable is treated as a statement handle that is used for execute and
fetch operations.
4. Edit anyco.php. Modify the construct_employees() function. Remove the
query text and the bind arguments. The function becomes:
function construct_employees()
{
$deptid = $_SESSION['deptid'];
$conn = db_connect($err);
if (!$conn) {
handle_error('Connection Error', $err);
}
else {
$emp = db_get_employees_rc($conn, $deptid, $err);
if (!$emp) {
handle_error('Cannot fetch Employees', $err);
}
else {
$deptname = get_dept_name($conn, $deptid);
ui_print_header('Employees: '.$deptname);
ui_print_employees($emp, $_SERVER['SCRIPT_NAME']);
ui_print_footer(date('Y-m-d H:i:s'));
}
}
}
5. Save the changes to your application files. In a browser, enter the following URL to
test the application:
http://localhost/~<username>/chap6/anyco.php
6. In the Departments form, click Next > to navigate to the Marketing department
page.