I tried to run the MySQL stored procedure SQL script by Liquibase, but never worked.
The content of db.storedprocedure.xml:
<changeSet author="zzz" id="1" runOnChange="true" runInTransaction="true">
<sqlFile path="changelogs/change_03.sql"
relativeToChangelogFile="true"
endDelimiter="$$"
stripComments="false"
splitStatements="false"/>
</changeSet>
The content of my SQL file change_03.sql:
$$
CREATE PROCEDURE `liqui01`.`User_Search`(
INOUT id INT,
OUT name VARCHAR(50)
)
BEGIN
SET @sql = CONCAT("SELECT id, name FROM user WHERE da.MarketId = ", id );
PREPARE stmt from @sql;
EXECUTE stmt;
END$$
It shows the error like:
Unexpected error running Liquibase: 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 '$$ ...
I've tried to change the "$$" to other delimiters, or put the SQL inside <sql>
tags of the XML file, all didn't work.
Any advise would be appreciated!
Update 1
@Shadow has given the correct answer (unfortunately I cannot mark it as the answer because it's in the comments), removing the delimeter lines from the sql scripts will make it work, thanks for him!
Now the question is: How to use "endDelimiter" parameter?