PL/SQL Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to PL/SQL. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 3 - What is the output of the following code?

DECLARE
   x number := 4;
BEGIN
   LOOP
      dbms_output.put_line(x);
      x := x + 1;
      exit WHEN x > 5;
   END LOOP;
      dbms_output.put_line(x);
END;

A - 4

     5

     6

B - 4

     5

C - 4

D - None of the above.

Answer : A

Q 5 - Observe the following code and fill in the blanks −

DECLARE 
   total_rows number(2);
BEGIN
   UPDATE employees
   SET salary = salary + 500;
   IF ____________ THEN
      dbms_output.put_line('no employees selected');
   ELSIF ___________ THEN
      total_rows := _____________;
      dbms_output.put_line( total_rows || ' employees selected ');
   END IF; 
END;

A - %notfound, %found, %rowcount.

B - sql%notfound, sql%found, sql%rowcount.

C - sql%found, sql%notfound, sql%rowcount.

D - %found, %notfound, %rowcount.

Answer : B

Q 6 - The following code tries to fetch some information from all the rows in a table named customers for use in a PL/SQL block. What is wrong in the following code?

DECLARE
   c_id customers.id%type;
   c_name customers.name%type;
   c_addr customers.address%type;
   CURSOR c_customers is
      SELECT id, name, address FROM customers;
BEGIN
   LOOP
      FETCH c_customers into c_id, c_name, c_addr;
      EXIT WHEN c_customers%notfound;
      dbms_output.put_line(c_id || ' ' || c_name || ' ' || c_addr);
   END LOOP;
   CLOSE c_customers;
END;

A - It need not use a cursor.

B - The cursor is not opened.

C - It will not print information from all the rows.

D - There is nothing wrong in the code.

Answer : B

plsql_questions_answers.htm
Advertisements