Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to Run this PLSQL Block.

Re: How to Run this PLSQL Block.

From: <ThomasO_at_cpas.com>
Date: 27 Nov 2006 09:17:21 -0800
Message-ID: <1164647841.138089.48830@14g2000cws.googlegroups.com>

On Nov 27, 8:23 am, "you..._at_gmail.com" <you..._at_gmail.com> wrote:
> Hello guys,
>
> I am trying to right this plsql block that has nested loop. The place
> where I am stuck is that how do I get a substitute for this :
> << j_loop >> FOR j IN 40 .. 57 ( this is what I am doing and it would
> loop for all the numbers from 40 to 57)
>
> What I want to acheive is :
>
> << j_loop >> FOR j IN (40, 41, 45, 51,55, 57) -- here there is no
> specific pattern, its just a list of number that I want to loop for.
>
> Any suggestions.

Try Collections:
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#sthref994

create or replace procedure TESTLOOP is
TYPE typeANum IS TABLE OF NUMBER;
aItems typeANum ;
nItems PLS_INTEGER;
begin
  aItems := typeANum(40, 41, 45, 51,55, 57);   nItems := aItems.COUNT;
  FOR i IN 1..nItems LOOP
   Dbms_Output.put_line(to_char(aItems(i)));   END LOOP;
end TESTLOOP;

HTH
Thomas Received on Mon Nov 27 2006 - 11:17:21 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US