DBMS 186 Ex9
DBMS 186 Ex9
ROLL NO-2200290110186
SEC-5C
EXPERIMENT-9
A) Create a explicit cursor which updates the salary of an employee
such that,
1. If salary > 10000, then increase the salary by 15%
2. If 5000<salary <10000, then increase the salary by 12%
3. Otherwise, increase the salary by 10%
B) Write a trigger to ensure that no employee of age less than 25
can be inserted in the database.
-- Creating the Employees table for testing
CREATE TABLE Employees (
emp_id INT PRIMARY KEY,
salary DECIMAL(10, 2)
);
-- PL/SQL Block
DECLARE
CURSOR emp_cursor IS
SELECT emp_id, salary FROM Employees;
v_emp_id Employees.emp_id%TYPE;
v_salary Employees.salary%TYPE;
BEGIN
OPEN emp_cursor;
LOOP
FETCH emp_cursor INTO v_emp_id, v_salary;
EXIT WHEN emp_cursor%NOTFOUND;
-- Viewing data
SELECT * FROM Employees;
FINAL TABLE