Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdddg\tdddg_subprograms048.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:25Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Traversing Sparse Associative Arrays" /> <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_subprograms047.htm" title="Previous" type="text/html" /> <link rel="next" href="tdddg_subprograms049.htm" title="Next" type="text/html" /> <title>Traversing Sparse Associative Arrays</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_subprograms047.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_subprograms049.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="BABCBIED" name="BABCBIED"></a><a id="TDDDG99948" name="TDDDG99948"></a></p> <div class="sect2"><!-- infolevel="all" infotype="General" --> <h1>Traversing Sparse Associative Arrays</h1> <a name="BEGIN" id="BEGIN"></a> <p>A <span class="bold">sparse associative array</span> (indexed by string) might have gaps between elements. You can traverse it with a statement, as in the following example.</p> <p>To run the code in the following example, which prints the elements of the <code>job_titles</code> array:</p> <ol> <li> <p>At the end of the declarative part of the example in <a href="tdddg_subprograms045.htm#BABBIBHD">Declaring Associative Arrays</a>, insert this variable declaration:</p> <pre xml:space="preserve" class="oac_no_warn"> i jobs_.job_id%TYPE; </pre></li> <li> <p>In the executable part of the example in <a href="tdddg_subprograms046.htm#BABJHJBJ">Populating Associative Arrays</a> , after the code that populates the <code>job_titles</code> array, insert the code from <a href="#CIHFADJH">Example: Traversing a Sparse Associative Array</a>.</p> </li> </ol> <p>The following example includes two collection method invocations, <code>job_titles</code>.<code>FIRST</code> and <code>job_titles</code>.<code>NEXT(i)</code>. <code>job_titles.FIRST</code> returns the first element of <code>job_titles</code>, and <code>job_titles</code>.<code>NEXT(i)</code> returns the subscript that succedes <code>i</code>. For more information about <code>FIRST</code>, see <a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=LNPLS99965','newWindow').focus()"><span class="italic">Oracle Database PL/SQL Language Reference</span></a>. For more information about <code>NEXT</code>, see <a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=LNPLS99964','newWindow').focus()"><span class="italic">Oracle Database PL/SQL Language Reference</span></a>.</p> <div class="example"><a id="CIHFADJH" name="CIHFADJH"></a><a id="TDDDG246" name="TDDDG246"></a> <p class="titleinexample">Traversing a Sparse Associative Array</p> <pre xml:space="preserve" class="oac_no_warn"> /* Declare this variable in declarative part: i jobs_.job_id%TYPE; Add this code to the executable part, after code that populates job_titles: */ i := <span class="bold">job_titles.FIRST</span>; WHILE i IS NOT NULL LOOP DBMS_OUTPUT.PUT_LINE(RPAD(i, 12) || job_titles(i)); i := <span class="bold">job_titles.NEXT(i)</span>; END LOOP; </pre> <p>Result:</p> <pre xml:space="preserve" class="oac_no_warn"> AC_ACCOUNT Public Accountant AC_MGR Accounting Manager AD_ASST Administration Assistant AD_PRES President AD_VP Administration Vice President FI_ACCOUNT Accountant FI_MGR Finance Manager HR_REP Human Resources Representative IT_PROG Programmer MK_MAN Marketing Manager MK_REP Marketing Representative PR_REP Public Relations Representative PU_CLERK Purchasing Clerk PU_MAN Purchasing Manager SA_MAN Sales Manager SA_REP Sales Representative SH_CLERK Shipping Clerk ST_CLERK Stock Clerk ST_MAN Stock Manager </pre></div> <!-- class="example" --> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="tdddg_subprograms030.htm#BABIECGJ">Using the WHILE LOOP Statement</a></p> <p><a href="tdddg_subprograms042.htm#BABDFGAA">Using Associative Arrays</a></p> </div> </div> <!-- class="sect2" --> <!-- class="sect1" --> <!-- 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_subprograms047.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_subprograms049.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