ORA-00927:缺少等号

时间:2015-05-15 04:32:58

标签: sql oracle triggers

我正在创建我的第一个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

1 个答案:

答案 0 :(得分:2)

  

SET 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

此外,在引用OLD和NEW值时这是不正确的:

:NEW.salary