PLSQL: CURSORS, WITH FOR LOOP, PARAMETERISED CURSORS, UPDATABLE CURSORS

30 programming challenges to help you master the fundamentals of DATABASE MANAGEMENT SYSTEM USING ORACLE.

1

Write a PL/SQL block to declare a cursor to fetch all employees from EMP table and display their names.

(Explicit Cursor)

2

Write a PL/SQL block to fetch employee name and salary using cursor and display them.

(Explicit Cursor)

3

Write a PL/SQL block to display employees whose salary is greater than 3000 using cursor.

(Explicit Cursor + Condition)

4

Write a PL/SQL block to count number of employees using cursor.

(Explicit Cursor)

5

Write a PL/SQL block to calculate total salary of all employees using cursor.

(Explicit Cursor + Aggregate)

6

Write a PL/SQL block to fetch records one by one using OPEN, FETCH, and CLOSE.

(Cursor Lifecycle)

7

Write a PL/SQL block to display all employee records using cursor FOR LOOP.

(Cursor FOR LOOP)

8

Write a PL/SQL block to display employee names and jobs using cursor FOR LOOP.

(Cursor FOR LOOP)

9

Write a PL/SQL block to display employees from department 10 using cursor FOR LOOP.

(Cursor FOR LOOP + Condition)

10

Write a PL/SQL block to calculate total salary using cursor FOR LOOP.

(Cursor FOR LOOP)

11

Write a PL/SQL block to display employees with salary greater than average using cursor FOR LOOP.

(Cursor FOR LOOP + Subquery)

12

Write a PL/SQL block to declare a parameterized cursor that takes department number and displays employees of that department.

(Parameterized Cursor)

13

Write a PL/SQL block to fetch employees whose salary is greater than a given value using parameterized cursor.

(Parameterized Cursor)

14

Write a PL/SQL block to display employees based on job role using parameterized cursor.

(Parameterized Cursor)

15

Write a PL/SQL block to calculate total salary of a given department using parameterized cursor.

(Parameterized Cursor + Aggregate)

16

Write a PL/SQL block to pass multiple parameters (deptno, job) to cursor and display matching records.

(Parameterized Cursor)

17

Write a PL/SQL block to update salary of employees using cursor with FOR UPDATE.

(Updatable Cursor)

18

Write a PL/SQL block to increase salary by 10% for employees using WHERE CURRENT OF.

(Updatable Cursor)

19

Write a PL/SQL block to delete employees with salary less than 2000 using cursor.

(Updatable Cursor + DELETE)

20

Write a PL/SQL block to update job of employees using updatable cursor.

(Updatable Cursor)

21

Write a PL/SQL block to fetch records using cursor and modify values row-by-row.

(Updatable Cursor)

22

Write a PL/SQL block using explicit cursor and IF condition to display high salary employees.

(Cursor + IF)

23

Write a PL/SQL block using cursor FOR LOOP and calculate bonus (10% of salary).

(Cursor FOR LOOP + Calculation)

24

Write a PL/SQL block using parameterized cursor and loop through multiple departments.

(Parameterized Cursor + LOOP)

25

Write a PL/SQL block to update and display employee data using updatable cursor.

(Updatable Cursor + Output)

26

Write a PL/SQL block to display top 3 highest paid employees using cursor.

(Cursor + Logic)

27

Write a PL/SQL block to simulate pagination (fetch limited rows using cursor).

(Cursor Advanced)

28

Write a PL/SQL block to copy employee data into another table using cursor.

(Cursor + INSERT)

29

Write a PL/SQL block to display department-wise employee count using cursor.

(Cursor + Grouping Logic)

30

Write a PL/SQL block to process employee records and apply different salary increments based on job using cursor.

(Cursor + Business Logic)