Oracle Database: Program with PL/SQL — Question 14

In your schema, the DEPARTMENTS table contains the columns DEPARTMENT_ID and DEPARTMENT_NAME.
You want to display the department name for existing department id 10.
With SERVEROUTPUT enabled, which two blocks of code will give the required output?

Answer options

Correct answer: C, D

Explanation

Option C correctly uses a PL/SQL block with a cursor to select the department name for the specified department ID and outputs it using DBMS_OUTPUT. Option D tries to execute an immediate block but contains syntax errors and misuses the cursor. Options A and B either incorrectly handle the cursor or do not conform to the requirements specified in the question.