Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > ebb1914cf182a88528b4547490db1dd8 > files > 1194

kdewebdev-quanta-doc-3.5.9-2mdv2008.1.x86_64.rpm

<HTML
><HEAD
><TITLE
>OCINewCursor</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="manual.html"><LINK
REL="UP"
TITLE="Oracle 8 functions"
HREF="ref.oci8.html"><LINK
REL="PREVIOUS"
TITLE="OCIStatementType"
HREF="function.ocistatementtype.html"><LINK
REL="NEXT"
TITLE="OCIFreeStatement"
HREF="function.ocifreestatement.html"></HEAD
><BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><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.ocistatementtype.html"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="function.ocifreestatement.html"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.ocinewcursor"
>OCINewCursor</A
></H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN20974"
></A
>OCINewCursor -- return a new cursor (Statement-Handle) - use this to bind ref-cursors!</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN20977"
></A
><H2
>Description</H2
><DIV
CLASS="funcsynopsis"
><P
></P
><CODE
CLASS="FUNCDEF"
>int OCINewCursor</CODE
>(int conn);<P
></P
></DIV
><P
>&#13;     <B
CLASS="function"
>OCINewCursor()</B
> allocates a new statement handle on the specified
     connection.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 1. Using a REF CURSOR from a stored procedure</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php   
  3&nbsp;// suppose your stored procedure info.output returns a ref cursor in :data
  4&nbsp;
  5&nbsp;$conn = OCILogon("scott","tiger");
  6&nbsp;$curs = OCINewCursor($conn);
  7&nbsp;$stmt = OCIParse($conn,"begin info.output(:data); end;");
  8&nbsp;
  9&nbsp;ocibindbyname($stmt,"data",&#38;$curs,-1,OCI_B_CURSOR);
 10&nbsp;ociexecute($stmt);
 11&nbsp;ociexecute($curs);
 12&nbsp;
 13&nbsp;while (OCIFetchInto($curs,&#38;$data)) {
 14&nbsp;    var_dump($data);
 15&nbsp;}
 16&nbsp; 
 17&nbsp;OCIFreeCursor($stmt);
 18&nbsp;OCIFreeStatement($curs);
 19&nbsp;OCILogoff($conn);
 20&nbsp;?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><P
><B
>Example 2. Using a REF CURSOR in a select statement</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="programlisting"
>  1&nbsp;
  2&nbsp;&#60;?php   
  3&nbsp;print "&#60;HTML&#62;&#60;BODY&#62;";
  4&nbsp;$conn = OCILogon("scott","tiger");
  5&nbsp;$count_cursor = "CURSOR(select count(empno) num_emps from emp " .
  6&nbsp;                "where emp.deptno = dept.deptno) as EMPCNT from dept";
  7&nbsp;$stmt = OCIParse($conn,"select deptno,dname,$count_cursor");
  8&nbsp;
  9&nbsp;ociexecute($stmt);
 10&nbsp;print "&#60;TABLE BORDER=\"1\"&#62;";
 11&nbsp;print "&#60;TR&#62;";
 12&nbsp;print "&#60;TH&#62;DEPT NAME&#60;/TH&#62;";
 13&nbsp;print "&#60;TH&#62;DEPT #&#60;/TH&#62;";
 14&nbsp;print "&#60;TH&#62;# EMPLOYEES&#60;/TH&#62;";
 15&nbsp;print "&#60;/TR&#62;";
 16&nbsp;
 17&nbsp;while (OCIFetchInto($stmt,&#38;$data,OCI_ASSOC)) {
 18&nbsp;    print "&#60;TR&#62;";
 19&nbsp;    $dname  = $data["DNAME"];
 20&nbsp;    $deptno = $data["DEPTNO"];
 21&nbsp;    print "&#60;TD&#62;$dname&#60;/TD&#62;";
 22&nbsp;    print "&#60;TD&#62;$deptno&#60;/TD&#62;";
 23&nbsp;    ociexecute($data[ "EMPCNT" ]);
 24&nbsp;    while (OCIFetchInto($data[ "EMPCNT" ],&#38;$subdata,OCI_ASSOC)) {
 25&nbsp;        $num_emps = $subdata["NUM_EMPS"];
 26&nbsp;        print  "&#60;TD&#62;$num_emps&#60;/TD&#62;";
 27&nbsp;    }
 28&nbsp;    print "&#60;/TR&#62;";
 29&nbsp;}
 30&nbsp;print "&#60;/TABLE&#62;";
 31&nbsp;print "&#60;/BODY&#62;&#60;/HTML&#62;";
 32&nbsp;OCIFreeStatement($stmt);
 33&nbsp;OCILogoff($conn);
 34&nbsp;?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="function.ocistatementtype.html"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="manual.html"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="function.ocifreestatement.html"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>OCIStatementType</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="ref.oci8.html"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>OCIFreeStatement</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>