lab4
CREATE OR REPLACE TRIGGER SALARY_DIFF_TRIG
BEFORE INSERT OR UPDATE OR DELETE ON CUSTOMER
FOR EACH ROW
DECLARE
old_salary number;
new_salary number;
BEGIN
IF INSERTING THEN
DBMS.OUTPUT.PUT_LINE('NEW SALARY:'||:NEW.salary);
ELSIF UPDATING THEN
old_salary:=:OLD.salary;
new_salary:=:NEW.salary;
IF old_salary IS NULL THEN
old_salary:=0;
END IF;
IF new_salary IS NULL THEN
new_salary:=0;
END IF;
DBMS.OUTPUT.PUT_LINE('Old Salary'||old_salary);
DBMS.OUTPUT.PUT_LINE('New Salary'||new_salary);
DBMS.OUTPUT.PUT_LINE('SALARY DIFF'||(new_salary-old_salary));
ELSIF DELETING THEN
DBMS.OUTPUT.PUT_LINE('Old Salary'||:OLD.salary);
END IF;
END;
/
first do set serveroutput ON
then create table()
then edit filename
then a prompt will open write all program except insert and update operation
then after saving close the program
then write @filename then do insert and update operation
Comments
Post a Comment