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

Home -> Community -> Usenet -> c.d.o.misc -> Re: PLSQL: Looping thru Variables

Re: PLSQL: Looping thru Variables

From: Gunjeet Singh <gunjeet_at_sunsparkle.ebay.sun.com>
Date: 11 Aug 1998 18:53:29 GMT
Message-ID: <6qq3v9$6am$1@ebaynews1.Ebay.Sun.COM>


Your procedure is being passed the strins 'var1', 'var2' and 'var3'. One way of doing this is to use a PL/SQL table to store the values are then use it as an array.

To do this, declare a PL/SQL table to hold the values of var1 till varN.

TYPE CarNameType IS TABLE OF VARCHAR2 INDEX BY BINARY_INTEGER;

car_tab CarNameType;

car_tab(1) := 'CHEVY';
car_tab(2) := 'SATURN';
car_tab(3) := 'OLDS';

FOR i IN 1..3 LOOP
	foo(car_tab(i));

 END LOOP; In fact you can store all the values that you need to pass b/w your procedures in a PL/SQL table and pass the table itself to the other procedure.

Hope this helps.

Gunjeet

In article 3987573_at_news.northgrum.com, mark_aurit_at_mail.northgrum.com (Mark Aurit) writes:
> I call a routine, passing it 3 variables: var1,var2,var3, which
> contain the values 'CHEVY','SATURN','OLDS' (actually, a lot more than
> 3 get passed).
>
> From that routine, I want to call another, passing it the values of
> the variables from within a loop, along the lines of:
>
> FOR i = 1..3 LOOP
> foo('var'||i);
> END LOOP;
>
> Foo() is receiving the values 'var1','var2','var3', and not
> 'CHEVY','SATURN','OLDS'.
>
> Any help would be greatly appreciated.
>
> Mark
> mark_aurit AT mail.northgrum.com
Received on Tue Aug 11 1998 - 13:53:29 CDT

Original text of this message

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