Oracle B25-317-01 Manual de usuario Pagina 69

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 94
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 68
Using PL/SQL Ref Cursors to Return Result Sets
Beta Draft Executing Stored Procedures and Functions 6-7
In the Results section, confirm the package body is successfully created:
3. Edit anyco_db.inc. Create a new PHP function that calls the PL/SQL packaged
procedure:
// Use ref cursor to fetch employee records
// All records are retrieved - there is no paging in this example
function db_get_employees_rc($conn, $deptid, &$e)
{
// Excute the call to the stored procedure
$stmt = "BEGIN cv_types.get_employees($deptid, :rc); END;";
$stid = @oci_parse($conn, $stmt);
if (!$stid) {
$e = db_error($conn, __FILE__, __LINE__);
return false;
}
$refcur = oci_new_cursor($conn);
if (!$stid) {
$e = db_error($conn, __FILE__, __LINE__);
return false;
}
$r = @oci_bind_by_name($stid, ':RC', $refcur, -1, OCI_B_CURSOR);
if (!$r) {
$e = db_error($stid, __FILE__, __LINE__);
return false;
}
$r = @oci_execute($stid);
if (!$r) {
$e = db_error($stid, __FILE__, __LINE__);
return false;
}
// Now treat the ref cursor as a statement resource
$r = @oci_execute($refcur, OCI_DEFAULT);
if (!$r) {
$e = db_error($refcur, __FILE__, __LINE__);
return false;
}
$r = @oci_fetch_all($refcur, $employeerecords, null, null,
OCI_FETCHSTATEMENT_BY_ROW);
Vista de pagina 68
1 2 ... 64 65 66 67 68 69 70 71 72 73 74 ... 93 94

Comentarios a estos manuales

Sin comentarios