Control Structures  «Prev  Next»

PL/SQL Control Structures - Quiz

Test your knowledge of PL/SQL control structures

Each question is worth one point. Select the best answer for each question.
 
1. Evaluate the value of amount in the PL/SQL block below:
/* Start main block */
DECLARE
order_id NUMBER := 101;
product_id VARCHAR2(4) := 'DOGGY';
amount NUMBER(9,2);
BEGIN
IF order_id > 100 AND dept_code = 'DOG' THEN
amount := 100;
ELSE 
amount := 50;
END IF;
END;

Please select the best answer.
  A. 100
  B. 50
  C. 0
  D. Cannot be deduced

2. What would be assigned to pet_commission if pet_sales is set to 500 in the PL/SQL block below?
IF pet_sales < 100 THEN
pet_commission := (pet_sales * 10 / 100);
ELSIF pet_sales < 200 THEN
 pet_commission := (pet_sales * 20 / 100);
ELSIF pet_sales < 300 THEN
 pet_commission := (pet_sales * 30 / 100);
ELSE
 pet_commission := (pet_sales * 50 / 100); 
END IF

Please select the best answer.
  A. 50
  B. 100
  C. 150
  D. 250

3. How many nested IF clauses can be included within an IF clause?
Please select the best answer.
  A. 0
  B. 1
  C. 15
  D. Any number

4. What is the maximum number of ELSE clauses that can be included in an IF clause that is not nested?
Please select the best answer.
  A. 0
  B. 1
  C. 15
  D. Any number

5. 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;

Please select the best answer.
  A. 0
  B. 1
  C. 99
  D. 100
Correct answers:

Your Score: 0