SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table customers(id int primary key,name varchar(10),age int,address varchar(15),salary decimal(10,2)); drop trigger if exists salary_difference_trigger create trigger if not exists salary_difference_trigger before insert or update or delete on customers for each row declare old_salary decimal(10,2); new_salary decimal(10,2); begin if inserting or updating then old_salary := NVL(:old.salary,0); new_salary :=NVL(:new.salary,0); dbms_output.put_line('Salary difference:'||(new_salary-old_salary)); elseif deleting then old_salary :=NVL(:old.salary,0); dbms_output.put_line('salary before deletion:'||old_salary); end if; end; /

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear