Oracle Database Programming MCQs with Answers
Practice important Oracle Database Programming MCQs with answers and explanations.
Chapter: 11
Q161:
What does the %NOTFOUND attribute of a cursor indicate?
A. Whether the cursor is open
B. Whether a row was fetched
C. Whether the previous FETCH returned a row
D. Whether the cursor has been closed
Correct Answer:
C
Chapter: 11
Q162:
Which cursor attribute returns the number of records fetched?
A. %ROWCOUNT
B. %FOUND
C. %NOTFOUND
D. %ISOPEN
Correct Answer:
A
Chapter: 11
Q163:
What is the first step in processing a cursor?
A. Fetching the cursor
B. Closing the cursor
C. Opening the cursor
D. Declaring the cursor
Correct Answer:
D
Chapter: 11
Q164:
In the implicit cursor example, what will %ROWCOUNT show after the update statement?
A. Number of rows updated
B. Number of rows inserted
C. Number of rows deleted
D. Number of rows fetched
Correct Answer:
A
Chapter: 11
Q165:
What is the purpose of the FETCH statement in PL/SQL cursors?
A. To close the cursor
B. To open the cursor
C. To retrieve data from the cursor
D. To declare the cursor
Correct Answer:
C
Chapter: 11
Q166:
How is an explicit cursor defined in a PL/SQL block?
A. In the BEGIN section
B. In the DECLARE section
C. In the EXECUTE section
D. In the OPEN section
Correct Answer:
B
Chapter: 11
Q167:
What does the %ISOPEN attribute of a cursor indicate?
A. If the cursor has processed all rows
B. If the cursor is currently open
C. If the cursor has been declared
D. If the cursor is being fetched
Correct Answer:
B
Chapter: 11
Q168:
Which PL/SQL block demonstrates the use of an explicit cursor to display employee names and designations?
A. Processing Explicit Cursor –I
B. Processing Explicit Cursor –II
C. Processing Explicit Cursor –III
D. Processing Explicit Cursor –IV
Correct Answer:
A
Chapter: 11
Q169:
In which cursor example is the total salary updated and displayed for employees with at least 10 years of service?
A. Processing Explicit Cursor –V
B. Processing Explicit Cursor –VI
C. Processing Explicit Cursor with SQL–I
D. Processing Explicit Cursor with SQL–II
Correct Answer:
C
Chapter: 11
Q170:
How are rows processed in the FOR loop with an explicit cursor?
A. Using FETCH statements
B. Using INSERT statements
C. Using UPDATE statements
D. Automatically without explicit FETCH
Correct Answer:
D
Chapter: 11
Q171:
Fill in the blank: The attribute _______ returns TRUE if the cursor is open.
A. %ISOPEN
B. %FOUND
C. %ROWCOUNT
D. %NOTFOUND
Correct Answer:
A
Chapter: 11
Q172:
What does the PL/SQL block in "Processing Explicit Cursor –VI" do?
A. Displays names and jobs of clerks with a manager number greater than 120
B. Updates salaries for employees with a manager number greater than 120
C. Inserts data into a temp table if the sum of salaries exceeds 20000
D. Displays the bottom 4 salaries from the employee table
Correct Answer:
A
Chapter: 11
Q173:
In which processing example is a cursor used to insert rows into a temp table based on the sum of salaries?
A. Processing Explicit Cursor –V
B. Processing Explicit Cursor –VI
C. Processing Explicit Cursor with SQL–I
D. Processing Explicit Cursor with SQL–II
Correct Answer:
D
Chapter: 12
Q174:
What is the primary purpose of handling exceptions in PL/SQL?
A. Avoid program termination
B. Optimize code performance
C. Increase database security
D. Reduce syntax errors
Correct Answer:
A
Chapter: 12
Q175:
Which of the following is an example of an internal exception in PL/SQL?
A. No Data Found
B. Duplicate Value
C. Invalid Number
D. Zero Division Error
Correct Answer:
A
Chapter: 12
Q176:
What does the `WHEN others` clause in an exception block handle?
A. Specific exceptions
B. User-defined exceptions
C. All exceptions not explicitly handled
D. Internal exceptions
Correct Answer:
C
Chapter: 12
Q177:
In PL/SQL, what must a user-defined exception be explicitly raised with?
A. EXCEPTION block
B. Raise statement
C. BEGIN block
D. THEN statement
Correct Answer:
B
Chapter: 12
Q178:
Which section of a PL/SQL block contains executable statements?
A. Exception Section
B. Declare Section
C. Begin Section
D. End Section
Correct Answer:
C
Chapter: 12
Q179:
What will the output be if a `SELECT` statement in PL/SQL returns more than one row?
A. Record not matched
B. Unique Key Violated
C. ORA-01422: exact fetch returns more than requested number of rows
D. Invalid Number
Correct Answer:
C
Chapter: 12
Q180:
What does the `SQLERRM` function return in an exception block?
A. The SQL error code
B. The error message associated with the exception
C. The name of the exception
D. The error description
Correct Answer:
B