PL/SQL Mock Test



This section presents you various set of Mock Tests related to PL/SQL. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

PL/SQL Mock Test III

Q 2 - Which of the following code will open a cursor named cur_employee?

A - OPEN cur_employee;

B - OPEN CURSOR cur_employee;

C - FETCH cur_employee;

D - FETCH CURSOR cur_employee;

Answer : A

Q 3 - 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

Q 5 - Which of the following is not among the types of PL/SQL records?

A - Table-based

B - View-based

C - Cursor-based records

D - User-defined records

Answer : B

Q 7 - Which of the following code will successfully declare an exception named emp_exception1 in a PL/SQL block?

A - EXCEPTION emp_exception1;

B - emp_exception1 EXCEPTION;

C - CREATE EXCEPTION emp_exception1;

D - CREATE emp_exception1 AS EXCEPTION;

Answer : B

Q 8 - Consider the exception declared as −

emp_exception1 EXCEPTION;

Which of the following statement will correctly call the exception in a PL/SQL block?

A - IF c_id <= 0 THEN ex_invalid_id;

B - IF c_id <= 0 THEN CALL ex_invalid_id;

C - IF c_id <= 0 THEN RAISE ex_invalid_id;

D - IF c_id <= 0 THEN EXCEPTION ex_invalid_id;

Answer : C

Q 15 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

The INSTEAD OF clause is used for creating trigger on a −

A - View

B - Cursor

C - Table

D - Index

Answer : A

Q 16 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

The {INSERT [OR] | UPDATE [OR] | DELETE} clause specifies a

A - DDL operation.

B - DML operation.

C - None of the above.

D - Both of the above.

Answer : B

Q 17 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

The optional [FOR EACH ROW] clause specifies

A - A table with index.

B - A table with primary key.

C - A row level trigger.

D - A table with a unique key.

Answer : C

Q 18 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

Which of the following holds true for the WHEN clause?

A - This provides a condition for rows for which the trigger would fire and this clause is valid only for row level triggers.

B - This provides a condition for rows for which the trigger would fire and this clause is valid only for table level triggers.

C - This provides a condition for rows for which the trigger would fire and this clause is valid only for view based triggers.

D - All of the above.

Answer : A

Q 19 - Observe the syntax given below −

CREATE [OR REPLACE ] TRIGGER trigger_name 
{BEFORE | AFTER | INSTEAD OF } 
{INSERT [OR] | UPDATE [OR] | DELETE} 
[OF col_name] 
ON table_name 
[REFERENCING OLD AS o NEW AS n] 
[FOR EACH ROW] 
WHEN (condition)  
DECLARE
   Declaration-statements
BEGIN 
   Executable-statements
EXCEPTION
   Exception-handling-statements
END;

Which of the following holds true for the [REFERENCING OLD AS o NEW AS n] clause?

A - This allows you to refer new and old values for various DML statements, like INSERT, UPDATE, and DELETE.

B - OLD and NEW references are not available for table level triggers.

C - You can use them for record level triggers.

D - All of the above.

Answer : D

Q 21 - All objects placed in a package specification are called

A - Public objects.

B - Private objects.

C - None of the above.

D - Both of the above.

Answer : A

Q 22 - Any subprogram not in the package specification but coded in the package body is called a

A - Public object.

B - Private object.

C - None of the above.

D - Both of the above.

Answer : B

Answer Sheet

Question Number Answer Key
1 A
2 A
3 B
4 D
5 B
6 A
7 B
8 C
9 A
10 B
11 C
12 D
13 D
14 C
15 A
16 B
17 C
18 A
19 D
20 A
21 A
22 B
23 D
24 C
25 A
plsql_questions_answers.htm
Advertisements