Home » SQL & PL/SQL » SQL & PL/SQL » Explain code (Oracle,11.2.0.2.0 - Production,Win7)
Explain code [message #632727] Wed, 04 February 2015 23:35 Go to next message
shumail
Messages: 149
Registered: September 2012
Location: Canada
Senior Member
Hi All

I'm wondering that if somebody explain the below code:

CREATE OR REPLACE PACKAGE   BODY p1ch_pkg
IS
   PROCEDURE show_nt
   IS
      l_index   pls_integer := g_nt.FIRST;
   BEGIN
        --  g_nt:=nt();
  -- dbms_output.put_line(11111);
      while l_index IS NOT NULL
      loop
         dbms_output.put_line ('l_index='||l_index || '-' || g_nt (l_index));
         l_index := g_nt.NEXT (l_index);
      END loop;
   END;
END;


I store 1,2,3,4,5 values in g_nt and then call this procedure, the thing that I don't understand is the counter that is l_index := g_nt.NEXT (l_index);.. Can somebody explain me how does this counter works?. Thanks in advance


Lalit : Removed superfluous lines in the end

[Updated on: Thu, 05 February 2015 00:36] by Moderator

Report message to a moderator

Re: Explain code [message #632729 is a reply to message #632727] Thu, 05 February 2015 00:39 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
g_nt is an array, l_index is the iterator, thus g_nt.NEXT (l_index) gives the next value in the array.
Re: Explain code [message #632731 is a reply to message #632727] Thu, 05 February 2015 00:53 Go to previous message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

2 good books for you:
PL/SQL User's Guide and Reference
Application Developer's Guide - Fundamentals

Previous Topic: How to make logic
Next Topic: More than one column in Connect by prior
Goto Forum:
  


Current Time: Thu Aug 27 02:28:31 CDT 2026