Oracle Database PL/SQL Developer Certified Professional Exam Test

Preparing for the Oracle Database PL/SQL Developer Certified Professional exam? Testing your knowledge beforehand is key to identifying your strengths and areas that need attention. Here are 25 multiple-choice questions to help you get ready. Each question comes with the correct answer and an explanation to reinforce your understanding.

1. Which of the following statements correctly declares a variable in PL/SQL?

A) var NUMBER;
B) NUMBER var;
C) DECLARE var NUMBER;
D) var NUMBER DECLARE;

Answer:

A) var NUMBER;

Explanation:

In PL/SQL, variables are declared by specifying the variable name, followed by the data type.

2. What does the SQLERRM function return?

A) Error number
B) Error message
C) Error code
D) None of the above

Answer:

B) Error message

Explanation:

The SQLERRM function returns the error message associated with the most recently raised error exception.

3. Which of the following is a valid cursor type in PL/SQL?

A) OPEN
B) FETCH
C) REF CURSOR
D) CLOSE

Answer:

C) REF CURSOR

Explanation:

REF CURSOR is a type of cursor variable, allowing for the declaration and handling of cursor variables.

4. Which PL/SQL construct is used to handle exceptions in code?

A) EXCEPTION HANDLER
B) ERROR HANDLER
C) EXCEPTION
D) ERROR BLOCK

Answer:

C) EXCEPTION

Explanation:

The EXCEPTION construct in PL/SQL is used to handle exceptions and includes error-handling routines.

5. What is the purpose of the %TYPE attribute in PL/SQL?

A) To define a new data type
B) To determine the data type of a variable
C) To declare a variable of the same type as a table column
D) To check the type of a data structure

Answer:

C) To declare a variable of the same type as a table column

Explanation:

The %TYPE attribute is used to declare a variable of the same type as that of a specified table column.

6. Which of the following statements will successfully update a record in a table?

A) UPDATE table_name SET column1 = value1;
B) MODIFY table_name SET column1 = value1;
C) CHANGE table_name SET column1 = value1;
D) ALTER table_name SET column1 = value1;

Answer:

A) UPDATE table_name SET column1 = value1;

Explanation:

The UPDATE statement is used to modify the existing records in a table.

7. Which PL/SQL structure is used for repeating a block of statements?

A) LOOP
B) ITERATE
C) REPEAT
D) CYCLE

Answer:

A) LOOP

Explanation:

The LOOP statement is used to execute a block of statements multiple times.

8. Which PL/SQL package is utilized for outputting data to the console?

A) DBMS_OUTPUT
B) DBMS_CONSOLE
C) DBMS_PRINT
D) DBMS_DISPLAY

Answer:

A) DBMS_OUTPUT

Explanation:

The DBMS_OUTPUT package in PL/SQL is designed for displaying output, debugging information, and transmitting messages from various PL/SQL components like blocks, subprograms, packages, and triggers.

9. Which of the following is not a PL/SQL composite data type?

A) Table
B) Array
C) Record
D) Dictionary

Answer:

D) Dictionary

Explanation:

Dictionary is not a PL/SQL composite data type. The composite data types in PL/SQL include Table, Array, and Record.

10. What is the purpose of the %ROWTYPE attribute in PL/SQL?

A) Defines a type that represents a row from a table or view
B) Defines a type that represents a column from a table or view
C) Defines a type that represents a data type from a table or view
D) None of the above

Answer:

A) Defines a type that represents a row from a table or view

Explanation:

The %ROWTYPE attribute is used to declare a record that represents a row in a table or a row fetched from a cursor.

11. Which operator is used for concatenation in PL/SQL?

A) CONCAT
B) &
C) ||
D) +

Answer:

C) ||

Explanation:

The || operator is used for string concatenation in PL/SQL.

12. Which of the following is a valid way to assign a value to a variable in PL/SQL?

A) SET variable_name = value;
B) variable_name := value;
C) variable_name -> value;
D) variable_name = value;

Answer:

B) variable_name := value;

Explanation:

In PL/SQL, the := operator is used to assign a value to a variable.

13. Which PL/SQL package provides procedures to output values in SQL*Plus?

A) DBMS_SQL
B) DBMS_OUTPUT
C) SQL_UTIL
D) PLSQL_OUTPUT

Answer:

B) DBMS_OUTPUT

Explanation:

The DBMS_OUTPUT package provides procedures to output values in SQL*Plus, including the PUT_LINE procedure for printing lines.

14. What is the primary purpose of cursors in PL/SQL?

A) To fetch single rows from a table
B) To handle exceptions
C) To process individual elements in a collection
D) To handle sets of rows returned by a query

Answer:

D) To handle sets of rows returned by a query

Explanation:

Cursors in PL/SQL are used primarily to handle sets of rows returned by SQL queries for processing.

15. How do you exit a LOOP in PL/SQL?

A) EXIT;
B) BREAK;
C) STOP;
D) LEAVE;

Answer:

A) EXIT;

Explanation:

The EXIT statement is used to exit a LOOP in PL/SQL.

16. Which type of trigger is used to check and possibly cancel a DML statement?

A) INSTEAD OF
B) BEFORE
C) AFTER
D) COMPOUND

Answer:

B) BEFORE

Explanation:

BEFORE triggers are used to check conditions and possibly cancel the DML statement affecting the table.

17. What is the result of raising a ZERO_DIVIDE exception in PL/SQL?

A) The program terminates immediately.
B) The error is logged, and the program continues.
C) An error message is displayed, and control is transferred to the exception handler.
D) The division by zero is allowed, and a warning is issued.

Answer:

C) An error message is displayed, and control is transferred to the exception handler.

Explanation:

When a ZERO_DIVIDE exception is raised in PL/SQL, an error message is displayed, and control is transferred to the appropriate exception handler block.

18. Which of the following is not a PL/SQL composite data type?

A) RECORD
B) TABLE
C) VARRAY
D) LIST

Answer:

D) LIST

Explanation:

LIST is not a PL/SQL composite data type. The composite data types in PL/SQL are RECORD, TABLE, and VARRAY.

19. In which section of a PL/SQL block would you perform a commit?

A) Declaration
B) Execution
C) Exception
D) Closing

Answer:

B) Execution

Explanation:

A commit operation is typically performed in the Execution section of a PL/SQL block.

20. How can you catch any exception raised in a PL/SQL block?

A) By using a named exception
B) By using a WHEN OTHERS exception handler
C) By using a PRAGMA EXCEPTION_INIT
D) By using SQLCODE

Answer:

B) By using a WHEN OTHERS exception handler

Explanation:

The WHEN OTHERS exception handler is used to catch all exceptions that are not explicitly handled by named exception handlers in a PL/SQL block.

21. What is the primary purpose of using collections in PL/SQL?

A) To store exceptions
B) To store multiple elements of the same type
C) To handle cursors
D) To group related constants

Answer:

B) To store multiple elements of the same type

Explanation:

Collections in PL/SQL are used to store multiple elements, typically of the same data type. They are equivalent to arrays in other programming languages.

22. Which of the following is NOT a feature of Dynamic SQL in PL/SQL?

A) Execute Immediate
B) Open For
C) Fetch Bulk Collect
D) Compile Time Type Checking

Answer:

D) Compile Time Type Checking

Explanation:

Dynamic SQL in PL/SQL does not perform compile-time type checking since the SQL statement is constructed and executed at runtime.

23. Which PL/SQL package procedure is used for committing the current transaction?

A) COMMIT;
B) DBMS_TRANSACTION.COMMIT;
C) DBMS_COMMIT;
D) TRANSACTION.COMMIT;

Answer:

B) DBMS_TRANSACTION.COMMIT;

Explanation:

The DBMS_TRANSACTION.COMMIT procedure is used to commit the current transaction in PL/SQL.

24. What does the CONTINUE statement do in a PL/SQL loop?

A) Exits the loop immediately
B) Skips the current iteration and continues with the next
C) Continues execution from the start of the loop
D) Continues execution indefinitely

Answer:

B) Skips the current iteration and continues with the next

Explanation:

The CONTINUE statement in PL/SQL is used to skip the current iteration of the loop and continue with the next iteration.

25. How can you improve the performance of bulk fetches in PL/SQL?

A) By using the LIMIT clause
B) By using indexed collections
C) By increasing the fetch row count
D) By using parallel fetch

Answer:

A) By using the LIMIT clause

Explanation:

Using the LIMIT clause in bulk fetches allows you to specify the number of rows fetched at a time, thereby improving performance.

26. What is the scope of a package variable in PL/SQL?

A) The entire session
B) The current package
C) The current block
D) The entire database

Answer:

B) The current package

Explanation:

A package variable in PL/SQL has a scope limited to the current package.

27. Which of the following is NOT a subtype of the PLS_INTEGER data type?

A) BINARY_INTEGER
B) NATURAL
C) POSITIVE
D) UNSIGNED_INTEGER

Answer:

D) UNSIGNED_INTEGER

Explanation:

UNSIGNED_INTEGER is not a subtype of PLS_INTEGER. The subtypes of PLS_INTEGER are BINARY_INTEGER, NATURAL, and POSITIVE.

28. In PL/SQL, what will happen if an exception is raised but not handled?

A) The exception is ignored
B) The block terminates immediately
C) The exception is logged and the block continues
D) A runtime error occurs

Answer:

B) The block terminates immediately

Explanation:

If an exception is raised in a PL/SQL block and it is not handled by an appropriate exception handler, the block terminates immediately, and control transfers to the enclosing block or to the host environment.

29. Which type of PL/SQL collection allows nonconsecutive index values?

A) VARRAY
B) Nested Table
C) Associative Array
D) PL/SQL Table

Answer:

C) Associative Array

Explanation:

Associative Arrays in PL/SQL allow nonconsecutive index values, whereas Nested Tables and VARRAYs have consecutive indexes.

30. What is the purpose of the RAISE_APPLICATION_ERROR procedure?

A) To raise an informational message
B) To log errors
C) To raise a user-defined error exception
D) To terminate the application

Answer:

C) To raise a user-defined error exception

Explanation:

RAISE_APPLICATION_ERROR is a procedure in PL/SQL that enables the raising of user-defined error exceptions with a custom error number and message.

31. How can you prevent a trigger from executing multiple times in response to a single statement?

A) By using the FOR EACH ROW clause
B) By using the INSTEAD OF clause
C) By using the COMPOUND TRIGGER
D) By using the BEFORE EACH STATEMENT clause

Answer:

C) By using the COMPOUND TRIGGER

Explanation:

A compound trigger can be used to prevent a trigger from executing multiple times in response to a single SQL statement.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top