2017-09-24 16 views
0

创建此触发器时出现错误。我的目标是,如果我们将客户插入到客户表中,那么该银行的银行表中的客户列号应该更新。触发错误

DELIMITER @@ 
CREATE OR REPLACE TRIGGER USER.bank_trigger AFTER 
    INSERT ON customers FOR EACH row BEGIN 
    UPDATE bank 
    SET no_of_customers = no_of_customers + 1 
    WHERE bank_id  = new.bank_id 
END @@ DELIMITER ; 

回答

0

根据你的标签是Oracle 11g,您正在使用的CREATE TRIGGER语法不correct.Here是正确的语法。 :new代表触发器体内的列的新值。

CREATE OR REPLACE TRIGGER bank_trigger AFTER 
    INSERT ON customers FOR EACH row 
    BEGIN 
    UPDATE bank 
    SET no_of_customers = no_of_customers + 1 
    WHERE bank_id = :new.bank_id; 
END; 
/