ASSIGNMENT NO : 8
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT,
address VARCHAR(255),
salary DECIMAL(10,2)
);
INSERT INTO employees (id, name, age, address, salary) VALUES(1, 'John Doe', 30, '123 Main St, City
A', 55000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(2, 'Jane Smith', 28, '456 Oak St, City
B', 60000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(3, 'Mike Johnson', 35, '789 Pine St,
City C', 75000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(4, 'Emily Davis', 40, '321 Elm St, City
D', 80000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(5, 'Robert Brown', 25, '654 Maple St,
City E', 50000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(6, 'Linda White', 38, '987 Birch St,
City F', 72000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(7, 'James Wilson', 45, '741 Cedar St,
City G', 85000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(8, 'Patricia Martinez', 29, '852
Willow St, City H', 58000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(9, 'David Garcia', 33, '963 Aspen St,
City I', 69000.00);
INSERT INTO employees (id, name, age, address, salary) VALUES(10, 'Sarah Lee', 27, '159 Cherry St,
City J', 62000.00);
DECLARE
v_min_salary employees.salary%TYPE;
v_count NUMBER := 0;
BEGIN
-- Find the minimum salary from the employees table
SELECT MIN(salary) INTO v_min_salary FROM employees;
-- Update employees having the minimum salary
UPDATE employees
SET salary = salary + 5000
WHERE salary = v_min_salary;
-- Get the count of affected employees using SQL%ROWCOUNT (implicit cursor)
v_count := SQL%ROWCOUNT;
-- Display the count of updated employees
DBMS_OUTPUT.PUT_LINE('Number of employees whose salary increased: ' || v_count);
END;