loops [message #4083] |
Thu, 07 November 2002 09:03 |
Saritha Akurathi
Messages: 1 Registered: November 2002
|
Junior Member |
|
|
Hai ,
Iam trying to execute the following basic loop.
DECLARE
v_Num_Col NUMBER ;
v_Char_Col VARCHAR2(60) ;
v_Counter NUMBER :=0;
BEGIN
LOOP
INSERT INTO temp_table VALUES(&v_Num_Col,'&v_char_col ');
v_Counter := v_Counter + 1;
EXIT WHEN v_Counter > 3;
END LOOP;
END;
It is prompting me to enter the values only once.It is taking the same values for four times and inserting the same values for four times in to the table.
My question is how can i design the loop so that it can prompt me to enter new value for each iteration of the loop?i.e asking me to enter new value when counter is 1 and for new value when counter is 2 and so on.
|
|
|
Re: loops [message #4085 is a reply to message #4083] |
Thu, 07 November 2002 12:59 |
Andrew
Messages: 144 Registered: March 1999
|
Senior Member |
|
|
You can't really loop like that in sqlplus. You can do something like this:
t.sql
======
INSERT INTO temp_table VALUES(&v_Num_Col,'&v_char_col ');
@@t.sql
Problem is the script nests itself and will only go down to a level of 10 or 16 or something like that before dying.
|
|
|