Function.oci-new-cursor

Aus PHP-Wiki

Wechseln zu: Navigation, Suche
Kinderzimmer Natura von Zöllner und Wickelkommode Björn von PinolinoMotorradversicherung . Girokonto Vergleich

oci_new_cursor — Allocates and returns a new cursor (statement handle)

Inhaltsverzeichnis

Beschreibung

resource oci_new_cursor ( resource $connection )


Allocates a new statement handle on the specified connection.

Parameter-Liste

connection

Rückgabewerte

Returns a new statement handle, or FALSE on error.

Beispiele

=== #1 Using REF CURSOR in an Oracle's stored procedure

<?php
// suppose your stored procedure info.output returns a ref cursor in :data
 
$conn = oci_connect("scott", "tiger");
$curs = oci_new_cursor($conn);
$stmt = oci_parse($conn, "begin info.output(:data); end;");
 
oci_bind_by_name($stmt, "data", $curs,===
 
 
 
<source lang="php">
 
<?php
echo "";
$conn = oci_connect("scott", "tiger");
$count_cursor = "CURSOR(select count(empno) num_emps from emp " .
                "where emp.deptno = dept.deptno) as EMPCNT from dept";
$stmt = oci_parse($conn, "select deptno,dname,$count_cursor");
 
oci_execute($stmt);
echo "";
echo "";
echo "DEPT NAME";
echo "DEPT #";
echo "# EMPLOYEES";
echo "";
 
while ($data = oci_fetch_assoc($stmt)) {
    echo "";
    $dname  = $data["DNAME"];
    $deptno = $data["DEPTNO"];
    echo "$dname";
    echo "$deptno";
    oci_execute($data["EMPCNT"]);
    while ($subdata = oci_fetch_assoc($data["EMPCNT"])) {
        $num_emps = $subdata["NUM_EMPS"];
        echo  "$num_emps";
    }
    echo "";
}
echo "";
echo "";
oci_free_statement($stmt);
oci_close($conn);
?>

Anmerkungen

Hinweis: In PHP versions before 5.0.0 you must use ocinewcursor() instead. This name still can be used, it was left as alias of oci_new_cursor() for downwards compatability. This, however, is deprecated and not recommended.

Persönliche Werkzeuge