我创建了我的第一个sql触发器,
CREATE OR REPLACE TRIGGER totalsalary AFTER INSERT ON Employee FOR EACH ROW WHEN ( NEW.Dno IS NOT NULL ) BEGIN UPDATE Department SET totalSalary totalSalary + NEW.salary WHERE Dno = NEW.Dno; END ;
但我收到此错误消息,但我不知道如何解决它
Error at line 3: PL/SQL: ORA-00927: missing equal sign 1. CREATE OR REPLACE TRIGGER SueldoTotal 2. AFTER INSERT ON EMPLEADO 3. FOR EACH ROW 4. WHEN ( NEW.Dno IS NOT NULL ) 5. BEGIN
设置totalSalary totalSalary + NEW.salary
您在 SET* 子句中 缺少等号 。 *
CREATE OR REPLACE TRIGGER totalsalary AFTER INSERT ON Employee FOR EACH ROW WHEN ( NEW.Dno IS NOT NULL ) BEGIN UPDATE Department SET totalSalary = totalSalary + :NEW.salary WHERE Dno = :NEW.Dno; END; /
新工资
另外,在引用旧值和新值时,这是不正确的:
:NEW.salary