0% found this document useful (0 votes)
23 views3 pages

Assignment - 6 (PL SQL)

Uploaded by

j32546498
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)
23 views3 pages

Assignment - 6 (PL SQL)

Uploaded by

j32546498
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/ 3

ASSIGNMENT-6

PL/SQL

CREATE TABLE emp1 (

emp_id INT PRIMARY KEY,

emp_name VARCHAR(20),

base_salary INT,

conveyance_fee INT,

tax INT DEFAULT 0,

net_salary INT DEFAULT 0

);

insert into emp1 values(1,'Harsha',25000 , 4000,0,0 );

insert into emp1 values(2,'Vishal',35000 , 3000,0,0 );

insert into emp1 values(3,'Abhilaash',45000 , 2000,0,0 );

select * from emp1;


DECLARE

CURSOR cemp IS SELECT emp_id, base_salary FROM emp1;

BEGIN

FOR co IN cemp LOOP

IF co.base_salary <= 30000 THEN

UPDATE emp1

SET tax = 0.1 * base_salary

WHERE emp_id = co.emp_id;

ELSIF co.base_salary > 30000 THEN

UPDATE emp1

SET tax = 0.2 * base_salary

WHERE emp_id = co.emp_id;

END IF;

END LOOP;

UPDATE emp1

SET net_salary =base_salary+conveyance_fee-tax;

END;

select * from emp1;

You might also like