简体   繁体   中英

Error in your SQL syntax near 'DELIMITER'

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

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.

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

#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

I really don't understand what is wrong.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM