PL/SQL - Programming Language (MCQ) questions

Dear Readers, Welcome to PL/SQL multiple choice questions and answers with explanation. These objective type PL/SQL questions are very important for campus placement test and job interviews.

Specially developed for the PL/SQL freshers and professionals, these model questions are asked in the online technical test and interview of many IT companies.

1)   Which operators combine the results of two queries into one result? (PL/SQL)
- Published on 26 Jun 15

a. Set operator
b. Row Operator
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Set operator

Explanation:
The set operators combines the results of two queries into a single result. Queries which contain these set operators are known as compound queries.


2)   Which of the following returns the current value in a specified sequence. (PL/SQL)
- Published on 26 Jun 15

a. CURRVAL
b. NEXTVAL
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: CURRVAL

Explanation:
The CURRVAL returns the current value of the sequence.


3)   “NO_DATA_FOUND” and “TOO_MANY_ROWS” are the two most common errors found when executing a SELECT statement. (PL/SQL)
- Published on 26 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
The “NO_DATA_FOUND” error is where the program is not able to find any data. This type of error can be trapped by the exception block.
The “TOO_MANY_ROWS” error is where one row data is conflicting with another row data so it is unable to fetch a particular data. This error too can be trapped by the exception block.


4)   In PL/SQL, a warning or error condition is called an exception.
- Published on 26 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
An error condition during a program is known as an exception. The exception block is used in the program and an appropriate action is taken against the error condition.
There are 2 types of exceptions
1. System-defined exceptions
2. User-defined exceptions.


5)   The comparison methods are used for comparing objects. How many ways are available for comparing objects? (PL/SQL)
- Published on 26 Jun 15

a. 4
b. 1
c. 2
d. 5
Answer  Explanation 

ANSWER: 2

Explanation:
The 2 methods used for comparing objects are
Map Method- It is a function implemented in such a way that its values depends depends upon the value of the attributes

Order Method- It implements some internal logic for comparing two objects.


6)   Nested tables are a good choice when -
(PL/SQL)

- Published on 26 Jun 15

a. The index values are not consecutive.
b. There is no set number of index values. However, a maximum limit is imposed.
c. You need to delete or update some elements, but not all the elements at once.
d. You would usually create a separate lookup table, with multiple entries for each row of the main table, and access it through join queries.
e. All mentioned above
Answer  Explanation 

ANSWER: All mentioned above

Explanation:
A nested table is similar to index by table but it can be stored in the database columns. It can be considered as a single column table that can either be in a memory or as a column in a database table. The elements can be deleted or added anywhere in a nested table. It may even contain empty elements.


7)   PL/SQL: The DBMS_SQL package should be used in which of the following situations?
- Published on 24 Jun 15

a. 13. There is an unknown number of input or output variables, such as the number of column values returned by a query, that are used in a dynamic SQL statement.
b. The dynamic code is too large to fit inside a 32K bytes VARCHAR2 variable.
c. Both A & B
d. None of the above
Answer  Explanation 

ANSWER: Both A & B

Explanation:
The DBMS_SQL package provides an interface to use dynamic SQL to parse any data manipulation language (DML) or data definition language (DDL) statement using PL/SQL


8)   PL/SQL: Dynamic SQL enables you to build SQL statements dynamically at runtime.
- Published on 24 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
Dynamic SQL helps to write programs that refer SQL statements whose full text is not known until the runtime.


9)   PL/SQL: SIGNTYPE lets you restrict an integer variable to the values -1, 0, and 1, which is useful in programming tri-state logic.
- Published on 24 Jun 15

a. True
b. False
Answer  Explanation 

ANSWER: True

Explanation:
Signtype is a subtype of binary integer. It requires less storage.


10)   PL/SQL: Is it possible to define a NOT NULL field in a record?
- Published on 24 Jun 15

a. Yes
b. No
Answer  Explanation 

ANSWER: Yes

Explanation:
The not null field helps us return all the not null records. It is like giving a condition to the block or the expression.


1 2