PL/SQL output type question

Q.  In the PL/SQL block below, how many rows will be inserted in the messages table?

DECLARE
v_start_sales NUMBER := 2;
v_end_sales NUMBER := 100;
BEGIN
FOR i IN v_start_sales..v_end_sales LOOP
INSERT INTO messages(msgid)
VALUES v_start_sales;
END LOOP;
END;

- Published on 08 Jul 15

a. 0
b. 99
c. 1
d. 100

ANSWER: 99
 
The output will be 99 because the loop will start with 2 as v_start_sales NUMBER is declared as 2. The loop will go on until it reaches 100 as the v_end_sales NUMBER is declared as 100. So the loop will start with 2 and go on till 100. Its total comes to 99.

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)