Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdddg\tdddg_subprograms036.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-04-21T9:46:24Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="About Cursors" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10766-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdddg_subprograms035.htm" title="Previous" type="text/html" /> <link rel="next" href="tdddg_subprograms037.htm" title="Next" type="text/html" /> <title>About Cursors</title> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdddg_subprograms035.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_subprograms037.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="BABJBEGE" name="BABJBEGE"></a><a id="TDDDG45000" name="TDDDG45000"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>About Cursors</h1> <a name="BEGIN" id="BEGIN"></a> <p>When Oracle Database executes a SQL statement, it stores the result set and processing information in an unnamed <a id="sthref453" name="sthref453"></a>private SQL area. A pointer to this unnamed area, called a <a id="sthref454" name="sthref454"></a><span class="bold">cursor</span>, lets you <a id="sthref455" name="sthref455"></a><a id="sthref456" name="sthref456"></a>retrieve the rows of the result set one at a time. <a id="sthref457" name="sthref457"></a><span class="bold">Cursor attributes</span> return information about the state of the cursor.</p> <p>Every time you run either a SQL <a id="sthref458" name="sthref458"></a>DML statement or a PL/SQL <a id="sthref459" name="sthref459"></a><code>SELECT</code> <code>INTO</code> statement, PL/SQL opens an <a id="sthref460" name="sthref460"></a><a id="sthref461" name="sthref461"></a><span class="bold">implicit cursor</span><a id="sthref462" name="sthref462"></a>. You can get information about this cursor from its attributes, but you cannot control it. After the statement runs, the database closes the cursor; however, its attribute values remain available until another DML or <code>SELECT</code> <code>INTO</code> statement runs.</p> <p>PL/SQL also lets you declare explicit cursors. An <a id="sthref463" name="sthref463"></a><a id="sthref464" name="sthref464"></a><span class="bold">explicit cursor</span> has a name and is associated with a query (SQL <code>SELECT</code> statement)—usually one that returns multiple rows. After declaring an explicit cursor, you must open it (with the <code>OPEN</code> statement), fetch rows one at a time from the result set (with the <a id="sthref465" name="sthref465"></a><code>FETCH</code> statement), and close the cursor (with the <code>CLOSE</code> statement). After closing the cursor, you can neither fetch records from the result set nor see the cursor attribute values.</p> <p>The syntax for the value of an implicit <a id="sthref466" name="sthref466"></a>cursor attribute is <code>SQL</code><code><span class="codeinlineitalic">attribute</span></code> (for example, <code>SQL%FOUND</code>). <code>SQL</code><code><span class="codeinlineitalic">attribute</span></code> always refers to the most recently run DML or <code>SELECT</code> <code>INTO</code> statement.</p> <p>The syntax for the value of an explicit cursor attribute is <code><span class="codeinlineitalic">cursor_name</span></code> immediately followed by <code><span class="codeinlineitalic">attribute</span></code> (for example, <code>c1%FOUND</code>).</p> <p><a href="#BABCDDED">Table: Cursor Attribute Values</a> lists the <a id="sthref467" name="sthref467"></a>cursor attributes and the values that they can return. (Implicit cursors have additional attributes that are beyond the scope of this book.)</p> <div class="tblformal"><a id="TDDDG236" name="TDDDG236"></a><a id="sthref468" name="sthref468"></a><a id="BABCDDED" name="BABCDDED"></a> <p class="titleintable">Cursor Attribute Values</p> <table class="Formal" title="Cursor Attribute Values" summary="This table has three columns and four rows. The first column lists the four cursor attributes. The second column describes the information that the attribute returns for an implicit cursor. The third column describes the information that the attribute returns for an explicit cursor." dir="ltr" border="1" width="100%" frame="hsides" rules="groups" cellpadding="3" cellspacing="0"> <col width="18%" /> <col width="*" /> <col width="41%" /> <thead> <tr align="left" valign="top"> <th align="left" valign="bottom" id="r1c1-t44">Attribute</th> <th align="left" valign="bottom" id="r1c2-t44">Values for Explicit Cursor</th> <th align="left" valign="bottom" id="r1c3-t44">Values for Implicit Cursor</th> </tr> </thead> <tbody> <tr align="left" valign="top"> <td align="left" id="r2c1-t44" headers="r1c1-t44"> <p><a id="sthref469" name="sthref469"></a><a id="sthref470" name="sthref470"></a><code>%FOUND</code></p> </td> <td align="left" headers="r2c1-t44 r1c2-t44"> <p>If cursor is not open, <code>INVALID_CURSOR</code>.</p> <p>If cursor is open but no fetch was attempted, <code>NULL</code>.</p> <p>If the most recent fetch returned a row, <code>TRUE</code>.</p> <p>If the most recent fetch did not return a row, <code>FALSE</code>.</p> </td> <td align="left" headers="r2c1-t44 r1c3-t44"> <p>If no DML or <code>SELECT</code> <code>INTO</code> statement has run, <code>NULL</code>.</p> <p>If the most recent DML or <code>SELECT</code> <code>INTO</code> statement returned a row, <code>TRUE</code>.</p> <p>If the most recent DML or <code>SELECT</code> <code>INTO</code> statement did not return a row, <code>FALSE</code>.</p> </td> </tr> <tr align="left" valign="top"> <td align="left" id="r3c1-t44" headers="r1c1-t44"> <p><a id="sthref471" name="sthref471"></a><a id="sthref472" name="sthref472"></a><code>%NOTFOUND</code></p> </td> <td align="left" headers="r3c1-t44 r1c2-t44"> <p>If cursor is not open, <code>INVALID_CURSOR</code>.</p> <p>If cursor is open but no fetch was attempted, <code>NULL</code>.</p> <p>If the most recent fetch returned a row, <code>FALSE</code>.</p> <p>If the most recent fetch did not return a row, <code>TRUE</code>.</p> </td> <td align="left" headers="r3c1-t44 r1c3-t44"> <p>If no DML or <code>SELECT</code> <code>INTO</code> statement has run, <code>NULL</code>.</p> <p>If the most recent DML or <code>SELECT</code> <code>INTO</code> statement returned a row, <code>FALSE</code>.</p> <p>If the most recent DML or <code>SELECT</code> <code>INTO</code> statement did not return a row, <code>TRUE</code>.</p> </td> </tr> <tr align="left" valign="top"> <td align="left" id="r4c1-t44" headers="r1c1-t44"> <p><a id="sthref473" name="sthref473"></a><a id="sthref474" name="sthref474"></a><code>%ROWCOUNT</code></p> </td> <td align="left" headers="r4c1-t44 r1c2-t44"> <p>If cursor is not open, <code>INVALID_CURSOR</code>; otherwise, a number greater than or equal to zero.</p> </td> <td align="left" headers="r4c1-t44 r1c3-t44"> <p><code>NULL</code> if no DML or <code>SELECT</code> <code>INTO</code> statement has run; otherwise, a number greater than or equal to zero.</p> </td> </tr> <tr align="left" valign="top"> <td align="left" id="r5c1-t44" headers="r1c1-t44"> <p><a id="sthref475" name="sthref475"></a><a id="sthref476" name="sthref476"></a><code>%ISOPEN</code></p> </td> <td align="left" headers="r5c1-t44 r1c2-t44"> <p>If cursor is open, <code>TRUE</code>; if not, <code>FALSE</code>.</p> </td> <td align="left" headers="r5c1-t44 r1c3-t44"> <p>Always <code>FALSE</code>.</p> </td> </tr> </tbody> </table> <br /></div> <!-- class="tblformal" --> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdddg_selecting001.htm#BCGBIFBJ">About Queries</a></p> <p><a href="tdddg_dml001.htm#BCGBGBIE">About Data Manipulation Language (DML) Statements</a></p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=LNPLS01345','newWindow').focus()"><span class="italic">Oracle Database PL/SQL Language Reference</span></a> for more information about the <code>SELECT</code> <code>INTO</code> statement</p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=ADFNS100','newWindow').focus()"><span class="italic">Oracle Database Advanced Application Developer's Guide</span></a> for more information about using cursors in PL/SQL</p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=LNPLS00602','newWindow').focus()"><span class="italic">Oracle Database PL/SQL Language Reference</span></a> for more information about using cursors in PL/SQL</p> <p><a href="tdddg_subprograms032.htm#CIHHCJDI">Using Records and Cursors</a></p> </div> </div> <!-- class="sect2" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 1996, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdddg_subprograms035.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_subprograms037.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de