0% found this document useful (0 votes)
3 views2 pages

Program 8

The document outlines the creation of an 'employees' table with fields for id, name, age, address, and salary, followed by the insertion of ten employee records. It includes a PL/SQL block that finds the minimum salary among employees, increases it by 5000 for those affected, and displays the count of updated records. The script demonstrates basic SQL operations such as table creation, data insertion, and updating records based on a condition.

Uploaded by

Rohit Lande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Program 8

The document outlines the creation of an 'employees' table with fields for id, name, age, address, and salary, followed by the insertion of ten employee records. It includes a PL/SQL block that finds the minimum salary among employees, increases it by 5000 for those affected, and displays the count of updated records. The script demonstrates basic SQL operations such as table creation, data insertion, and updating records based on a condition.

Uploaded by

Rohit Lande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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;

You might also like