need the values of a variable inside a for loop [message #299744] |
Wed, 13 February 2008 01:43 |
swapnajojo
Messages: 40 Registered: June 2007 Location: India
|
Member |
|
|
Hi Friends ,
Please help me with this issue
I have created a procedure .
CREATE or replace procedure p AS
2 x1 varchar2(5):='a';
3 x2 varchar2(5):='b';
4 c varchar2(20);
5 v varchar2(10);
6 v2 varchar2(10);
7 rows int;
8 begin
9 for i in 1..2
10 loop
11 v:='x'||i;
12 dbms_output.put_line(v);
13 c:=c||v||',';
14 dbms_output.put_line(c);
15 end loop;
16* end;
SQL> /
Procedure created.
SQL> exec p
x1
x1,
x2
x1,x2,
PL/SQL procedure successfully completed.
Instead I need output like a,b
We need to use loop because we may have many variable like x1 to x100
Thanks In Advance
Binu
|
|
|
|
|
|
|
|
Re: need the values of a variable inside a for loop [message #299769 is a reply to message #299744] |
Wed, 13 February 2008 02:48 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
> We need to use loop because we may have many variable like x1 to x100
It is not possible to get variable content when "dynamically" creating its name, as it will not be visible in that scope.
Use one collection (TABLE OF or VARRAY) instead of many variables. It will be easy to loop it.
Otherwise you have to access the variables one by one.
|
|
|