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

Trigger Execution

DBMS

Uploaded by

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

Trigger Execution

DBMS

Uploaded by

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

Trigger Execution:

-- create

CREATE TABLE EMPLOYEE (

EId INTEGER ,

Ename TEXT ,

Salary INTEGER

);

-- insert

INSERT INTO EMPLOYEE VALUES (0001, 'AVANI', 30000);

INSERT INTO EMPLOYEE VALUES (0002, 'RAJ', 25000);

INSERT INTO EMPLOYEE VALUES (0003, 'IVA', 50000);

INSERT INTO EMPLOYEE VALUES (0007,'OM', 40000);

INSERT INTO EMPLOYEE VALUES (0006, 'AVI', 25000);

INSERT INTO EMPLOYEE VALUES (0009, 'NITI', 30000);

-- fetch

SELECT * FROM EMPLOYEE order by EId;

Create table backup

( EId INTEGER ,

Ename TEXT ,

Salary INTEGER);
create trigger salary_diff
before insert on EMPLOYEE
for each row
declare
salary_diff INTEGER;
begin
Insert into backup values(: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:':salary_diff);
end;

You might also like