<HTML ><HEAD ><TITLE >OCINewCursor</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.html"><LINK REL="UP" TITLE="Oracle 8 functions" HREF="ref.oci8.html"><LINK REL="PREVIOUS" TITLE="OCINewCollection" HREF="function.ocinewcollection.html"><LINK REL="NEXT" TITLE="OCINewDescriptor" HREF="function.ocinewdescriptor.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.ocinewcollection.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.ocinewdescriptor.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.ocinewcursor" ></A >OCINewCursor</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN67354" ></A ><P > (PHP 3>= 3.0.8, PHP 4 )</P >OCINewCursor -- Return a new cursor (Statement-Handle) </DIV ><DIV CLASS="refsect1" ><A NAME="AEN67357" ></A ><H2 >Description</H2 >int <B CLASS="methodname" >OCINewCursor</B > ( int conn)<BR ></BR ><P > <B CLASS="function" >OCINewCursor()</B > allocates a new statement handle on the specified connection. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN67368" ></A ><P ><B >Example 1. Using a REF CURSOR from a stored procedure</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" ><?php // suppose your stored procedure info.output returns a ref cursor in :data $conn = OCILogon("scott","tiger"); $curs = OCINewCursor($conn); $stmt = OCIParse($conn,"begin info.output(:data); end;"); ocibindbyname($stmt,"data",&$curs,-1,OCI_B_CURSOR); ociexecute($stmt); ociexecute($curs); while (OCIFetchInto($curs,&$data)) { var_dump($data); } OCIFreeStatement($stmt); OCIFreeCursor($curs); OCILogoff($conn); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN67372" ></A ><P ><B >Example 2. Using a REF CURSOR in a select statement</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="programlisting" ><?php print "<HTML><BODY>"; $conn = OCILogon("scott","tiger"); $count_cursor = "CURSOR(select count(empno) num_emps from emp " . "where emp.deptno = dept.deptno) as EMPCNT from dept"; $stmt = OCIParse($conn,"select deptno,dname,$count_cursor"); ociexecute($stmt); print "<TABLE BORDER=\"1\">"; print "<TR>"; print "<TH>DEPT NAME</TH>"; print "<TH>DEPT #</TH>"; print "<TH># EMPLOYEES</TH>"; print "</TR>"; while (OCIFetchInto($stmt,&$data,OCI_ASSOC)) { print "<TR>"; $dname = $data["DNAME"]; $deptno = $data["DEPTNO"]; print "<TD>$dname</TD>"; print "<TD>$deptno</TD>"; ociexecute($data["EMPCNT"]); while (OCIFetchInto($data["EMPCNT"],&$subdata,OCI_ASSOC)) { $num_emps = $subdata["NUM_EMPS"]; print "<TD>$num_emps</TD>"; } print "</TR>"; } print "</TABLE>"; print "</BODY></HTML>"; OCIFreeStatement($stmt); OCILogoff($conn); ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.ocinewcollection.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.ocinewdescriptor.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >OCINewCollection</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.oci8.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >OCINewDescriptor</TD ></TR ></TABLE ></DIV ></BODY ></HTML >