IF规则的触发器导致Mysql语法错误

时间:2016-12-15 08:21:31

标签: mysql triggers

Hello All我正在努力使用以下查询创建一个触发器并且它会给出语法错误,有人可以帮助我。

MySQL版本5.7.14

代码:

CREATE TRIGGER `after_itgwp_users_insert` AFTER
INSERT ON `itgwp_users`
FOR EACH ROW
    IF USER() = 'root@localhost' THEN
        INSERT INTO audits (OPERATION, row_id,TABLE_NAME,`logical_table_name`,`status`)
        VALUES ('insert',
                NEW.ID,
                'itgwp_users',
                'contacts',
                'need_approve');

    END IF;

此触发器有效,但不是上述触发器:

CREATE TRIGGER `after_wp_posts_insert` AFTER INSERT ON `itgwp_posts`
 FOR EACH ROW IF  USER() = 'wp_sync@localhost' THEN
    INSERT INTO audits (operation, row_id,table_name,`logical_table_name`) values ('insert', NEW.ID, 'itgwp_posts', NEW.post_type);
    END IF

1 个答案:

答案 0 :(得分:1)

您必须首先更改分隔符,然后使用开始结束块

public class MyActivity extends AppCompatActivity implements MyFragmentCommunicator{

    @Override
    public void sendDataToActivity(String name, String image, String price) {
        //Manipulate the data
    }

}