【发布时间】:2011-12-14 12:18:15
【问题描述】:
我正在使用以下 sql:
DELIMITER $$
DROP PROCEDURE IF EXISTS `get_auto_increment_settings`$$
CREATE PROCEDURE `get_auto_increment_settings`()
BEGIN
select @@global.auto_increment_offset as 'offset', @@global.auto_increment_increment as 'increment' ;
END $$
DELIMITER ;
我将它存储在 db_auto_increment_settings_procedure.sql 中,当我尝试从 ant 执行它时,我遇到以下错误:
[sql] Executing resource: /mysql/install/db_auto_increment_settings_procedure.sql
[sql] Failed to execute: DELIMITER
[sql] com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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
[sql] Failed to execute: DELIMITER ;
[sql] com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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
【问题讨论】:
-
您的脚本是有效的 SQL - 这个问题将与您用来解释它的任何内容有关,我猜是因为
$在某种程度上是一个特殊字符。 -
我尝试使用“//”,但问题再次出现。
-
你用什么来解释 SQL? “//”不是常用来作为cmets的标记吗?
-
一点提示:
DELIMITER不是常规的 SQL 语句。它是 MySQL 客户端(如 MySQL 捆绑的命令行客户端)提供的命令。如果 DB 库没有实现它,则需要将文件解析为单独的语句。不知道如何在 Ant 中做到这一点。