Database Schema
Use the following tables for this assignment:
1. Employees Table
CREATE TABLE Employees (
EmpID NUMBER PRIMARY KEY,
Name VARCHAR2(50),
Department VARCHAR2(50),
Salary NUMBER
);
2. Audit Table
CREATE TABLE Salary_Audit (
AuditID NUMBER PRIMARY KEY,
EmpID NUMBER,
OldSalary NUMBER,
NewSalary NUMBER,
UpdatedBy VARCHAR2(50),
UpdatedOn DATE
);
Tasks
1. Cursor
Write a PL/SQL block that:
Uses a cursor to fetch employee details (Name and Salary) whose salaries exceed a specified
value.
Displays these details using DBMS_OUTPUT.
Example Output:
Employee: John, Salary: 60000
Employee: Alice, Salary: 80000
2. Trigger
Create a trigger on the Employees table that:
Logs changes to employee salaries in the Salary_Audit table whenever an update occurs.
Includes fields such as the old salary, new salary, employee ID, user updating the record, and
the timestamp.
3. Procedure
Create a stored procedure that:
Transfers an employee from one department to another.
Accepts the following parameters:
o Employee ID (EmpID)
o New Department Name (NewDept)
Updates the department in the Employees table and prints a confirmation message.