I am trying to execute a sql script which creates a procedure and execute it. I have verfier the procedure by running it manually from mysql client. But when is use the below script it gives an error.
my ant script is
<sql driver="${mysql.driver.string.DE}" url="jdbc:mysql://${database.host}:${database.port}/${database.name}" userid="${database.username}" password="${database.password}" onerror="continue" delimiter="$$" delimitertype="row" keepformat="yes" rdbms="mysql">
<transaction src="${mysql.dbupgrade.sql.dir.DE}/fixDuplicateClassNames.sql" />
<transaction>commit;</transaction>
<classpath>
<fileset dir="${lib.dir.DE}">
<include name="*.jar" />
</fileset>
</classpath>
</sql>
the error thrown on running the script is
java.sql.SQLException: Syntax error or access violation message from server: "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 $;
As I know the DELIMITER attribute are not possible in a “file-x.sql” used by ANT. You have to set it in the “sql.. tag”
if you set delimiter=”$$” and NOT delimitertype=”row” in the ANT script this will work. No need to switch back to “delimiter ;”
file-x.sql
Take care to set all $$, you can let the last line by “;” . But if you set the line above not ending with $$ — then ERROR. If you use delimitertype=”row” then all your $$ in the “file-x.sql” will be translated to $ (only one sign) and that throws many errors.