gpt4 book ai didi

sql - PL/SQL 和 SQL 脚本在一个带有 liquibase 的 sqlFile 中?

转载 作者:行者123 更新时间:2023-12-04 11:22:43 25 4
gpt4 key购买 nike

我尝试了很多选项来在包含 pl/sql 块和简单的 sql 语句的房间 changeSet/sqlFile 中运行。例如。:

BEGIN
aud.someProcedure('parameter');
END;
/
insert into test_table(_id, value) VALUES(1, 'test');

但我得到以下异常:
liquibase.exception.MigrationFailedException: Migration failed for change set [xml path]:
Reason: liquibase.exception.DatabaseException: ORA-06550: 4 line, 1 col:
PLS-00103: Encountered the symbol: "/"
[Failed SQL: BEGIN
aud.someProcedure('parameter');
END;
//
insert into test_table(_id, value) VALUES(1, 'test')
]
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:584)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)
at liquibase.Liquibase.update(Liquibase.java:210)
at liquibase.Liquibase.update(Liquibase.java:190)
at liquibase.Liquibase.update(Liquibase.java:186)
at org.jenkinsci.plugins.liquibase.builder.LiquibaseBuilder.perform(LiquibaseBuilder.java:128)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:381)
Caused by: liquibase.exception.DatabaseException: ORA-06550: 4 line, col oszlop:
PLS-00103: Encountered the symbol: "/"
[Failed SQL: BEGIN
aud.someProcedure('parameter');
END;
//
insert into test_table(_id, value) VALUES(1, 'test')
]

当我尝试在 xml 中更改 splitStatement 和 endDelimiter 时,没有任何改变。

你有什么想法吗?

最佳答案

“endDelimiter”完美运行。

SQL 语句中的分号会产生“无效字符错误”,因此当它不是分隔符时必须将其删除。
(是的,它在 PL/SQL 和 SQL*Plus 中工作,就像斜杠“/”,更多:When do I need to use a semicolon vs a slash in Oracle SQL?)

解决方案:

  • endDelimiter = "/"
    <changeSet id="1" author="me">
    <sql endDelimiter="/">
    BEGIN
    aud.someProcedure('parameter');
    END;
    /
    insert into test_table(_id, value) VALUES(1, 'test')
    </sql>
    </changeSet>
  • 两节
    <changeSet id="1" author="me">
    <sql endDelimiter="/">
    BEGIN
    aud.someProcedure('parameter');
    END;
    </sql>
    <sql>
    insert into test_table(_id, value) VALUES(1, 'test');
    </sql>
    </changeSet>
  • 或者可能 ;)
    <changeSet id="1" author="me">
    <sql endDelimiter="#Gabor was here#">
    BEGIN
    aud.someProcedure('parameter');
    END;
    #Gabor was here#
    insert into test_table(_id, value) VALUES(1, 'test')
    </sql>
    </changeSet>
  • 关于sql - PL/SQL 和 SQL 脚本在一个带有 liquibase 的 sqlFile 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32099621/

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