Dbmsexp7
Dbmsexp7
EXPERIMENT NO. 7
IMPLEMENTATION / COMMANDS:
1. 1). Write a Trigger for employee table which will display the salary difference.
PROCEDURE
(i) Create the employee table having columns empno, fname, lname, salary, address
(ii) Insert values
(iii)Write the after update trigger
(iv)Update the salary in employee table (v)
Display the difference in new and old salary
ANS:
(i) create table Employee
(
empno varchar(15),
fname varchar(15),
lname varchar(15),
salary integer,
Academic Year 2022-23 SAP ID:60003210190
address varchar(15)
);
desc Employee;
declare
sal_dif integer;
begin sal_dif:= :new.salary -:old.salary;
dbms_output.put_line('old salary:'||:old.salary);
dbms_output.put_line('new salary:'||:new.salary);
dbms_output.put_line('salary Difference:'||sal_dif);
end;
update Employee
set salary = salary+20000
where fname ='Sarthak'
Academic Year 2022-23 SAP ID:60003210190
desc grades;
a) Create a trigger GRADES_TRG that calculates the value of the Avg_M column.
a) Create a trigger GRADES_TRG that calculates the value of the Avg_M column.
a) Create a trigger GRADES_TRG that calculates the value of the Avg_M column.
Academic Year 2022-23 SAP ID:60003210190
a) Create a trigger GRADES_TRG that calculates the value of the Avg_M column.
b) Create a trigger on table GRADES such that it restricts the entry of duplicate SENo.