PLSQL: STORED PROCEDURES, STORED FUNCTIONS

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

1

Write a stored procedure to display "Hello Oracle" using DBMS_OUTPUT.

(Stored Procedure – Basic)

2

Write a stored procedure to display employee name for a given empno.

(Procedure + SELECT INTO)

3

Write a stored procedure to print salary of an employee.

(Procedure + SELECT)

4

Write a stored procedure to display all employees using cursor.

(Procedure + Cursor)

5

Write a stored procedure to display department details.

(Procedure – Basic)

6

Write a stored procedure that takes empno as input and displays employee details.

(IN Parameter)

7

Write a stored procedure that takes department number and displays employees of that department.

(IN Parameter)

8

Write a stored procedure that takes salary as input and displays employees earning more than that.

(IN Parameter)

9

Write a stored procedure with OUT parameter to return employee salary.

(OUT Parameter)

10

Write a stored procedure with IN OUT parameter to update salary and return new salary.

(IN OUT Parameter)

11

Write a stored procedure to insert a new employee record.

(Procedure + INSERT)

12

Write a stored procedure to update employee salary based on empno.

(Procedure + UPDATE)

13

Write a stored procedure to delete an employee record.

(Procedure + DELETE)

14

Write a stored procedure to increase salary of all employees by 10%.

(Procedure + UPDATE)

15

Write a stored procedure to transfer employees from one department to another.

(Procedure + Business Logic)

16

Write a function to return square of a number.

(Function – Basic)

17

Write a function to return employee salary based on empno.

(Function + SELECT INTO)

18

Write a function to return total number of employees.

(Function + Aggregate)

19

Write a function to return maximum salary from EMP table.

(Function + Aggregate)

20

Write a function to return department name based on deptno.

(Function)

21

Write a function to calculate bonus (10% of salary) and return it.

(Function + Calculation)

22

Write a function to return grade based on salary.

(Function + IF-ELSIF)

23

Write a function to check whether a number is even or odd.

(Function + Logic)

24

Write a function to return annual salary of an employee.

(Function + Calculation)

25

Write a function to return employee experience (based on hiredate).

(Function + Date Logic)

26

Write a procedure that calls a function to calculate bonus and display result.

(Procedure calling Function)

27

Write a function and use it inside SQL query.

(Function in SQL)

28

Write a procedure that uses function to update salary.

(Procedure + Function)

29

Write a function that returns highest salary and use it in procedure.

(Integration)

30

Write a stored procedure to display top 5 highest paid employees.

(Procedure + Advanced Query)

31

Write a stored function to return nth highest salary.

(Function + Logic)

32

Write a procedure to implement transaction (COMMIT / ROLLBACK).

(Procedure + Transaction Control)

33

Write a function that returns department-wise total salary.

(Function + GROUP BY)