Hi I was wondering if anyone can help me.
Given this PL/SQL block
v_counter INTEGER :=1;
v_upper INTEGER :=10;
WHILE v_counter = v_upper LOOP
INSERT INTO test(results)
IF v_counter = 5 THEN
v_upper := 7;
v_counter := v_counter + 2;
How many rows will be inserted into the test table? Choose the best answer
The answer given in my book is E. 4 But I don't know how they got this answer.
How do I read the Loop.????
Can you plug in the numbers to show me how you deal with this problem. Thanks.
IMHO there is a misprint in your book.
If they set v_counter :=1 and v_upper :=10 and just after that compare these variables in WHILE v_counter = v_upper they never can go inside the loop and the correct answer is 0.
But if we changed the condition to WHILE v_counter <= v_upper then the answer would be 4 and the example makes sense.
Click Here to Expand Forum to Full Width