java - Liquibase error Incorrect syntax near INT variable decleration - Stack Overflow

I'm getting the following error from a simple SQL tag in the XML file:Errorliquibase.exception.Da

I'm getting the following error from a simple SQL tag in the XML file:

Error

liquibase.exception.DatabaseException: Incorrect syntax near 'INT'.
[Failed SQL: (102) begin
DECLARE @MyVariable INT]

Code:

<changeSet  author="me"  id="poc" runAlways="true" runOnChange="true" >
    <sql>
    BEGIN
        DECLARE @MyVariable INT;
        SET @MyVariable = 10;
     END;
    </sql>
</changeSet>

SQL code block runs on a SQL Server 2019 with no issue.

I removed the semicolon as suggested in one of stackoverflow threads, it didn't help.

I'm getting the following error from a simple SQL tag in the XML file:

Error

liquibase.exception.DatabaseException: Incorrect syntax near 'INT'.
[Failed SQL: (102) begin
DECLARE @MyVariable INT]

Code:

<changeSet  author="me"  id="poc" runAlways="true" runOnChange="true" >
    <sql>
    BEGIN
        DECLARE @MyVariable INT;
        SET @MyVariable = 10;
     END;
    </sql>
</changeSet>

SQL code block runs on a SQL Server 2019 with no issue.

I removed the semicolon as suggested in one of stackoverflow threads, it didn't help.

Share Improve this question edited Nov 20, 2024 at 18:43 Dale K 27.5k15 gold badges58 silver badges83 bronze badges asked Nov 20, 2024 at 17:35 RickRick 971 silver badge13 bronze badges 2
  • i have a feeling liquidbase does some sort of batch splitting based on ; which is wrong, probably you didn't configure it properly for sql server specific dialect – siggemannen Commented Nov 20, 2024 at 18:33
  • 1 You can try splitStatements="false" perhaps, or use GO as end delimiter – siggemannen Commented Nov 20, 2024 at 18:55
Add a comment  | 

1 Answer 1

Reset to default 1

The issue was resolved by adding the attribute splitStatements="true" to the SQL tag. Thanks to @siggemannen for the helpful tip.

Updated code

<changeSet author="me" id="poc" runAlways="true" runOnChange="true" >
 <sql splitStatements="true">
  BEGIN
      DECLARE @MyVariable INT;
      SET @MyVariable = 10;
  END;
 </sql>
</changeSet>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742340681a4425563.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信