I am running the following SQL query:
Executing (default): DROP PROCEDURE IF EXISTS x;
DELIMITER $$
CREATE PROCEDURE x()
BEGIN
# do something
END $$
DELIMITER; $$
Like so:
sequelize.query(query, {
type: sequelize.QueryTypes.SELECT
});
But I get this error (even though it works just fine, if I use any other SQL client):
SequelizeDatabaseError: ER_PARSE_ERROR: 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 $$
CREATE PROCEDURE x()
BEGIN
I already added multipleStatements = true
to my connection config, but it does not do anything.
Update
I ended up using RAW
instead, like so:
sequelize.query(query, {
type: sequelize.QueryTypes.RAW
});
DELIMITER
is not part of MySQL server , it's part of the MySQL command line client . This feature is not available in the driver.
Source: https://github.com/mysqljs/mysql/issues/280#issuecomment-8081626
Your error is actually in the last line. Take out the $$
after DELIMITER;
The statement: DELIMITER;
resets the delimiter to ;
the $$
after that confuses the syntax analyzer.
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.