create trigger calculation after insert on employee
for each row
begin
if :new.updated_sal is null
then
update employee set updated_sal= (10/100)* salary
where id=:new.id;
end if;
end;
我想在employee表上創建一個觸發器,每當在同一個表中插入一條新記錄時,應該計算salary列中10%的salary并放入另一列updated_sal中。如果我嘗試插入新記錄,則表明該表已發生變異等
uj5u.com熱心網友回復:
這只是:new您需要的偽記錄:
create trigger calculation
after insert on employee
for each row
begin
if :new.updated_sal is null then
:new.updated_sal := (10/100) * :new.salary;
end if;
end;
uj5u.com熱心網友回復:
您需要在插入觸發器之前使用,并使用 :New.updated_sal:= :new.salary * somevalue 來分配工資。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/376670.html
上一篇:如何將視頻插入Oracle資料庫
