WorksheetsPL/SQL Quiz
Total questions: 60
Worksheet time: 30mins
PL/SQL is an extension of:
Java
C++
SQL
Python
What is the correct order of a PL/SQL block?
DECLARE, BEGIN, EXCEPTION, END
BEGIN, DECLARE, END
DECLARE, BEGIN, END, EXCEPTION
EXCEPTION, BEGIN, DECLARE, END
The symbol for assignment in PL/SQL is:
==
=
:=
=>
Single-line comment in PL/SQL is indicated by:
--
/*
//
BOOLEAN datatype can store:
Numbers
Characters
TRUE, FALSE, NULL
Dates
The operator for concatenation in PL/SQL is:
&
||
To print output in PL/SQL, which built-in package is used?
PUT_LINE
DBMS_OUTPUT
OUTPUT_DBMS
The keyword to end a PL/SQL block is:
STOP
EXIT
END
CLOSE
Conditional checking in PL/SQL is performed using:
LOOP
IF-ELSE
SWITCH
CASE-ELSE
%TYPE attribute is used to:
Declare new types
Match datatype of existing table columns
Create new tables
Delete columns
A PL/SQL variable must start with:
Letter
Digit
Symbol
Underscore
Which statement terminates loops?
CLOSE
STOP
EXIT
END LOOP
The keyword to declare a constant in PL/SQL:
FIXED
STATIC
CONSTANT
DEFINE
Which is a valid CASE statement syntax?
CASE THEN END
IF CASE END
CASE WHEN THEN ELSE END CASE
CASE IF ELSE END
In PL/SQL, exception handling is done by:
IGNORE
TRY
HANDLE
EXCEPTION
Character set symbols in PL/SQL can include:
Letters only
Digits only
Symbols like @, #, %, etc.
Spaces only
Multi-line comments are enclosed in:
-- and --
// and //
/* and */
and
Which is true about PL/SQL blocks?
It supports only procedural statements
It supports only SQL
Combines SQL with procedural statements
None of the above
PL/SQL's advantage is that it:
Increases network traffic
Reduces network traffic
Does not handle errors
Is not portable
What keyword defines a variable scope in a nested block?
NEST
LOCAL
DECLARE
PRIVATE
Cursor is essentially:
A database
A pointer to result set
A table
An array
%ROWTYPE is used for:
Declaring a record type
Creating new rows
Deleting rows
Counting rows
Explicit cursors must be:
Automatically opened
Manually created by Oracle
Manually opened and closed
Automatically closed
Implicit cursors handle:
Only SELECT statements
INSERT, UPDATE, DELETE, single-row SELECT
Multiple-row SELECT only
None of the above
Cursor attribute to check cursor open status:
%FOUND
%NOTFOUND
%ISOPEN
%ROWCOUNT
Cursor is declared with:
DECL cursor IS query;
CURSOR cursorname IS select_query;
CREATE CURSOR;
OPEN CURSOR;
Parameterized cursors:
Can be opened once
Can be opened multiple times with different parameters
Cannot accept parameters
Do not use parameters
FOR UPDATE clause is used to:
Open cursor
Fetch cursor data
Close cursor
Lock rows for updates or deletions
WHERE CURRENT OF clause:
References first row of cursor
References current row of cursor
References last row of cursor
Does not reference rows
Cursor FOR LOOP automatically:
Declares cursor
Opens and closes cursor
Handles exceptions
Updates cursor
Closing cursors improperly:
Frees resources immediately
Keeps resources allocated until session ends
Does not affect resources
Frees resources after transaction ends
To fetch data from a cursor:
FETCH FROM cursor
SELECT FROM cursor
FETCH cursor INTO variables
GET cursor data
Cursor attribute returning number of rows processed:
%ISOPEN
%FOUND
%NOTFOUND
%ROWCOUNT
Explicit cursors must NOT be used for:
SELECT statements
DML operations
Complex queries
Multiple-row operations
Cursor operations sequence:
OPEN, DECLARE, FETCH, CLOSE
FETCH, OPEN, CLOSE, DECLARE
DECLARE, OPEN, FETCH, CLOSE
CLOSE, OPEN, FETCH, DECLARE
Cursor is a reserved:
Function
Method
Procedure
Work area
Implicit cursor attribute after UPDATE:
CSR%FOUND
CSR%ROWCOUNT
CSR%NOTFOUND
SQL%ROWCOUNT
Explicit cursors can:
Automatically fetch data
Explicitly fetch data
Only handle single row
Cannot fetch data
Cursor attribute indicating no data fetched:
%FOUND
%NOTFOUND
%ISOPEN
%ROWCOUNT
Cursor data is known as:
Table
Set
Active data set
Active table
Exceptions handle:
Logical errors only
Runtime errors
Syntax errors only
Compilation errors
RAISE statement:
Ends block execution
Raises exception
Declares exception
Prevents exceptions
User-defined exceptions require:
Automatic raising
No declaration
Explicit declaration
None
Oracle built-in error NO_DATA_FOUND is:
ORA-06501
ORA-01476
ORA-06502
ORA-01403
SQLCODE returns:
Negative error code
Positive code
Message text
No value
PRAGMA EXCEPTION_INIT binds:
Error number to exception
Variable to exception
Cursor to exception
Table to exception
General name for unnamed errors:
ALL_ERRORS
ERROR_LIST
OTHERS
NONE
Error ORA-01476 indicates:
Invalid number
No data found
Zero divide
Rowtype mismatch
Built-in exceptions:
Must be manually raised
Are raised automatically by Oracle
Have no error number
Cannot be caught
PL/SQL error messages returned by:
ERRMSG
SQLERROR
SQLERRM
ERRORMSG
What occurs when an exception happens in PL/SQL?
PL/SQL immediately terminates without a message.
Control passes to the calling program.
Control passes to the exception handler.
Program continues executing normally.
Which built-in exception is raised if no rows are returned by a SELECT INTO statement?
TOO_MANY_ROWS
PROGRAM_ERROR
ACCESS_INTO_NULL
NO_DATA_FOUND
Which attribute returns the error message associated with the error code?
SQLCODE
SQLMESSAGE
SQLERROR
SQLERRM
Which error code range can be used for user-defined unnamed exceptions?
-10000 to -19999
-20000 to -20999
-21000 to -21999
-22000 to -22999
What is used to explicitly raise a user-defined exception?
EXCEPTION_INIT
PRAGMA_EXCEPTION
RAISE
SQLERRM
PRAGMA EXCEPTION_INIT binds an error number to which of the following?
Cursor names
Built-in exceptions
Variables
User-defined exceptions
Which keyword is used to handle exceptions not explicitly named?
SQLERRM
SQLCODE
OTHERS
DEFAULT
What statement is correct regarding user-defined exceptions?
Cannot be named.
Automatically handled by Oracle.
Must be explicitly declared by the user.
Only used for built-in errors.
When are built-in errors automatically raised by Oracle?
When a user explicitly raises them.
During normal execution without issues.
Whenever Oracle encounters a predefined error condition.
Only during database shutdown.
How is the error message displayed for unnamed user-defined exceptions?
Using the SQLCODE attribute.
Automatically displayed without any function.
Using built-in exception handlers only.
Using RAISE_APPLICATION_ERROR.
