引用mariadb语法时出错

时间:2018-03-21 19:04:12

标签: triggers mariadb

CREATE TRIGGER printMoneyUSA
    AFTER UPDATE ON USA
    REFERENCING
        OLD ROW AS old
        NEW ROW AS new

    FOR EACH ROW
BEGIN
    IF old.SUPPLY_OF_CURRENCY = 0 THEN
        SET new.SUPPLY_OF_CURRENCY = 30000000000;
    END IF;
END;//

您好,我继续收到“#REFERENCING'”的语法错误。语法说:

  

您的SQL语法有错误;查看与MariaDB服务器版本对应的手册,以便在

附近使用正确的语法
'REFERENCING
    OLD ROW AS old
    NEW ROW AS new

 FOR EACH ROW BEGI' at line 3.

有人可以指出我做错了什么吗?谢谢!

2 个答案:

答案 0 :(得分:0)

基于mariadb在create trigger上的文档,mariadb没有引用条款:

CREATE [OR REPLACE]
    [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]
    TRIGGER [IF NOT EXISTS] trigger_name trigger_time trigger_event
    ON tbl_name FOR EACH ROW
   [{ FOLLOWS | PRECEDES } other_trigger_name ]
   trigger_stmt

您必须删除引用子句,只需使用OLD / NEW来引用记录的版本。

答案 1 :(得分:0)

MariaDB和MySQL没有REFERENCING条款。 OLD会自动引用" old"行。同样适用于NEW