. Write a PL/SQL program to demonstrate Cursors.

Sure! Here's an example of a PL/SQL program that demonstrates the use of cursors:

```
DECLARE
CURSOR employee_cursor IS
SELECT employee_id, first_name, last_name, salary
FROM employees
WHERE salary > 5000;

emp_id employees.employee_id%TYPE;
emp_first_name employees.first_name%TYPE;
emp_last_name employees.last_name%TYPE;
emp_salary employees.salary%TYPE;
BEGIN
-- Open the cursor
OPEN employee_cursor;

-- Loop through the cursor
LOOP
-- Fetch the data into variables
FETCH employee_cursor INTO emp_id, emp_first_name, emp_last_name, emp_salary;

-- Exit the loop if no more records
EXIT WHEN employee_cursor%NOTFOUND;

-- Print the employee details
DBMS_OUTPUT.PUT_LINE('Employee ID: ' || emp_id);
DBMS_OUTPUT.PUT_LINE('Name: ' || emp_first_name || ' ' || emp_last_name);
DBMS_OUTPUT.PUT_LINE('Salary: ' || emp_salary || CHR(10));
END LOOP;

-- Close the cursor
CLOSE employee_cursor;
END;
/
```

In this program, we declare a cursor named `employee_cursor` that selects employee details from the `employees` table where the salary is greater than 5000. We also declare variables to hold the values of each column in the cursor.

We then open the cursor using the `OPEN` statement. Inside a loop, we fetch the data from the cursor into the variables using the `FETCH` statement. This retrieves the next record from the cursor.

We exit the loop when there are no more records to fetch using the `EXIT WHEN` statement. Within the loop, we use the `DBMS_OUTPUT.PUT_LINE` procedure to print the employee details to the console.

Finally, we close the cursor using the `CLOSE` statement. The forward slash (/) at the end of the program signifies the execution of the code.

When you run this program, it will print the employee IDs, names, and salaries for all employees with a salary greater than 5000 that exist in the `employees` table.