gpt4 book ai didi

java - Liquibase: 附近的语法不正确;

转载 作者:搜寻专家 更新时间:2023-11-01 01:54:15 24 4
gpt4 key购买 nike

我正在尝试使用 Liquibase 部署数据库更改,并在其中一个存储过程代码中出现以下错误。

SET NOCOUNT ON: Incorrect syntax near 'ON'.
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:104)
at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1075)
at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:1059)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
... 5 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'ON'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:197)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1493)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:775)
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:676)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4575)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1400)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:649)
at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)

sp 看起来像:

    CREATE PROCEDURE [dbo].[TestSP] 
AS
BEGIN

SET NOCOUNT ON;


SELECT Col1, Col2
FROM dbo.[Table1]

END
GO
GRANT EXECUTE ON [dbo].[testsp] TO [SomeRole]
GO

变更集看起来像:

<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<changeSet id="6a07201a-133e-4613-b4cf-15becbf53baf" author="Nadeem">

<sqlFile path="./Creation Scripts/Stored Procedures/testsp.sql" />
<rollback>
<sqlFile path="./Update Scripts/Stored Procedures/testsp.Rollback.sql" />
</rollback>
</changeSet>
</databaseChangeLog>

最佳答案

看起来您使用的是 <sql> <sqlFile> 重构标签。他们会自动将您的查询拆分为 ;GO .在这种情况下,这不是您想要的。

您可以设置属性 splitStatementsfalse或使用 <createProcedure> 而是重构标签。

关于java - Liquibase: 附近的语法不正确;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14832874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com