Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

oci new cursor function syntax tag tutorial 2013 Donate at flattr Flattr this





Alert! Connect with 10,000 Chating Online. Join Now

Php oci new cursor () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 5)

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

Syntax

resource oci_new_cursor ( resource connection )

oci_new_cursor() allocates a new statement handle on the specified connection.

Example 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, -1, OCI_B_CURSOR);
oci_execute($stmt);
oci_execute($curs);

while (
$data = oci_fetch_row($curs)) {
    
var_dump($data);
}

oci_free_statement($stmt);
oci_free_statement($curs);
oci_close($conn);
?>

Example 2. Using REF CURSOR in an Oracle's select statement

<?php   
echo "<html><body>";
$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
"<table border=\"1\">";
echo
"<tr>";
echo
"<th>DEPT NAME</th>";
echo
"<th>DEPT #</th>";
echo
"<th># EMPLOYEES</th>";
echo
"</tr>";

while (
$data = oci_fetch_assoc($stmt)) {
    echo
"<tr>";
    
$dname  = $data["DNAME"];
    
$deptno = $data["DEPTNO"];
    echo
"<td>$dname</td>";
    echo
"<td>$deptno</td>";
    
oci_execute($data["EMPCNT"]);
    while (
$subdata = oci_fetch_assoc($data["EMPCNT"])) {
        
$num_emps = $subdata["NUM_EMPS"];
        echo  
"<td>$num_emps</td>";
    }
    echo
"</tr>";
}
echo
"</table>";
echo
"</body></html>";
oci_free_statement($stmt);
oci_close($conn);
?>

oci_new_cursor() returns FALSE on error.

Note: 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.

Php oci new cursor Function syntax tag

oci new cursor php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php oci new cursor syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online