-
Hi I was wondering if anyone can help me.
Given this PL/SQL block
DECLARE
v_counter INTEGER :=1;
v_upper INTEGER :=10;
BEGIN
WHILE v_counter = v_upper LOOP
INSERT INTO test(results)
VALUES(v_counter);
IF v_counter = 5 THEN
v_upper := 7;
END IF;
v_counter := v_counter + 2;
END LOOP;
END;
How many rows will be inserted into the test table? Choose the best answer
A. 10
B. 7
C. 5
D. 3
E. 4
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.
-
Hi,
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|