'DELIMITER'附近的SQL语法出错

时间:2021-10-10 01:34:31

I wanted to create a TRIGGER for my database. The code is that:

我想为我的数据库创建一个TRIGGER。代码是:

DELIMITER ;

DROP TRIGGER  IF EXISTS `spi_financial_request_AINS`;

DELIMITER $$

CREATE
    DEFINER = CURRENT_USER 
    TRIGGER `spi_financial_request_AINS` AFTER INSERT ON   `spi_financial_request` 
    FOR EACH ROW BEGIN    
            DECLARE ev_id INT;       
                IF check_audit('spi_financial_request')=1 THEN  
              INSERT INTO spi_audit_event(table_name, record_id,event_type,user_id)
              VALUES('spi_financial_request',new.id,'INS',@user_id);
                  SELECT LAST_INSERT_ID() INTO ev_id;
INSERT INTO spi_audit_data(event_id,column_name,new_value)VALUES(ev_id,'id',new.id);
INSERT INTO spi_audit_data(event_id,column_name,new_value)VALUES(ev_id,'request_id',new.request_id);
INSERT INTO spi_audit_data(event_id,column_name,new_value)VALUES(ev_id,'payment_type_id',new.payment_type_id);
            END IF;
        END;
$$

DELIMITER ;

I've executed it on my local site (using SQLyog and 5.6.29 version of MySQL). It works.

我在我的本地站点上执行了它(使用SQLyog和5.6.29版本的MySQL)。有用。

But when I tried to use it on DEV server (using PHPMyAdmin and 5.6.32 version of MySQL), I've got an error:

但是当我尝试在DEV服务器上使用它时(使用PHPMyAdmin和5.6.32版本的MySQL),我遇到了一个错误:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1

#1064 - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的“DELIMITER”附近使用正确的语法

I really don't understand what is wrong.

我真的不明白有什么不对。

1 个解决方案

#1


0  

DELIMITER is a Mysql console command, You can't use it in phpmyadmin. To set the delimiter in phpmyadmin, see this other answer

DELIMITER是一个Mysql控制台命令,你不能在phpmyadmin中使用它。要在phpmyadmin中设置分隔符,请参阅此其他答案

#1


0  

DELIMITER is a Mysql console command, You can't use it in phpmyadmin. To set the delimiter in phpmyadmin, see this other answer

DELIMITER是一个Mysql控制台命令,你不能在phpmyadmin中使用它。要在phpmyadmin中设置分隔符,请参阅此其他答案