- PL/SQL - Home
- PL/SQL - Overview
- PL/SQL - Environment
- PL/SQL - Basic Syntax
- PL/SQL - Data Types
- PL/SQL - Variables
- PL/SQL - Constants and Literals
- PL/SQL - Operators
- PL/SQL - Conditions
- PL/SQL - Loops
- PL/SQL - Strings
- PL/SQL - Arrays
- PL/SQL - Procedures
- PL/SQL - Functions
- PL/SQL - Cursors
- PL/SQL - Records
- PL/SQL - Exceptions
- PL/SQL - Triggers
- PL/SQL - Packages
- PL/SQL - Collections
- PL/SQL - Transactions
- PL/SQL - Date & Time
- PL/SQL - DBMS Output
- PL/SQL - Object Oriented
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.
PL/SQL Mock Test III
Q 1 - Which of the following is the correct syntax for creating an explicit cursor?
A - CURSOR cursor_name IS select_statement;
B - CREATE CURSOR cursor_name IS select_statement;
Answer : A
Q 2 - Which of the following code will open a cursor named 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;
Answer : B
Q 4 - Which of the following is not true about PL/SQL records?
A - A PL/SQL record is a data structure that can hold data items of different kinds.
B - Records consist of different fields, similar to a row of a database table.
C - You can create table-based and cursor-based records by using the %ROWTYPE attribute.
Answer : D
Q 5 - Which of the following is not among the types of PL/SQL records?
Answer : B
Q 6 - Which of the following code correctly create a record named book with two field title and author?
A - TYPE book IS RECORD
(title varchar(50),
author varchar(50),
);
B - RECORD book
(title varchar(50),
author varchar(50),
);
C - CREATE RECORD book
(title varchar(50),
author varchar(50),
);
D - CREATE TYPE book
(title varchar(50),
author varchar(50),
);
Answer : A
Q 7 - Which of the following code will successfully declare an exception named emp_exception1 in a PL/SQL block?
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;
Answer : C
Q 9 - The pre-defined exception CASE_NOT_FOUND is raised when
B - PL/SQL has an internal problem.
C - A cursor fetches value in a variable having incompatible data type.
Answer : A
Q 10 - The pre-defined exception NO_DATA_FOUND is raised when
A - A null object is automatically assigned a value.
B - A SELECT INTO statement returns no rows.
Answer : B
Q 11 - The pre-defined exception TOO_MANY_ROWS is raised when
A - PL/SQL ran out of memory or memory was corrupted.
B - A cursor fetches value in a variable having incompatible data type.
Answer : C
Q 12 - Which of the following is not true about PL/SQL triggers?
A - Triggers are stored programs.
B - They are automatically executed or fired when some events occur.
Answer : D
Q 13 - Triggers are written to be executed in response to any of the following events −
A - A database manipulation (DML) statement (DELETE, INSERT, or UPDATE).
B - A database definition (DDL) statement (CREATE, ALTER, or DROP).
C - A database operation (SERVERERROR, LOGON, LOGOFF, STARTUP, or SHUTDOWN).
Answer : D
Q 14 - Which of the following is not a benefit of a database trigger?
A - Enforcing referential integrity
B - Event logging and storing information on table access
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 −
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
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
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?
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?
B - OLD and NEW references are not available for table level triggers.
Answer : D
Q 20 - Which of the following is true for querying a table in the same trigger?
Answer : A
Q 21 - All objects placed in a package specification are called
Answer : A
Q 22 - Any subprogram not in the package specification but coded in the package body is called a
Answer : B
Q 23 - Which of the following is not true about PL/SQL packages?
B - A package has two parts: Package specification and Package body or definition.
Answer : D
Q 24 - Which of the following is not true about PL/SQL package specifications?
A - The specification is the interface to the package.
C - It contains all information about the content of the package and the code for the subprograms.
Answer : C
Q 25 - Which of the following is true about PL/SQL package body?
Answer : A
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 |