2017-02-11 107 views
0

这是一个语法错误,我错过了一个空格或':'在我的代码中。下面是我的代码创建触发器sqlplus触发器编译错误

SQL> Create or replace trigger trig_addr_mulund 
     2 After insert or update 
     3 On users_table 
     4 For each row 
     5 begin 
     6 If :new.address like 'Mulund' then 
     7 Insert into [email protected] values (:new.id,:new.role_id,:new.b 
    ranch_id,:new.name,:new.email,:new.phone,:new.address, 
     8 :new.email,:new.phone,:new.address); 
     9 Else 
    10 Insert into [email protected] values (:new.id,:new.role_id,:n 
    ew.branch_id,:new.name,:new.email,:new.phone,:new.address, 
    11 :new.email,:new.phone,:new.address); 
    12 End if 
    13 End; 
    14/

Warning: Trigger created with compilation errors. 
+0

在看到该警告或查询'user_errors'视图后使用'show errors'来查看实际的编译错误。 –

回答

1

你缺少分号在您的生产线12的附近END IF

既然你正在做一个直接的比较,使用=代替LIKE。 另外,建议在SQL语句中显式提供列名。

CREATE OR REPLACE TRIGGER trig_addr_mulund AFTER 
    INSERT OR 
    UPDATE ON users_table FOR EACH row 
BEGIN 
    IF :new.address = 'Mulund' THEN -- changed "LIKE" to "=" 
    INSERT 
    INTO [email protected] VALUES 
    (
     :new.id, 
     :new.role_id, 
     :new.branch_id, 
     :new.name, 
     :new.email, 
     :new.phone, 
     :new.address, 
     :new.email, 
     :new.phone, 
     :new.address 
    ); 
ELSE 
    INSERT 
    INTO [email protected] VALUES 
    (
     :new.id, 
     :new.role_id, 
     :new.branch_id, 
     :new.name, 
     :new.email, 
     :new.phone, 
     :new.address, 
     :new.email, 
     :new.phone, 
     :new.address 
    ); 
END IF; -- added the missing semicolon 
END; 
/