我在更改集中定义了一个列,
<column name="LAST_MOD_TIME" type="date"/>
我有一个这样的插入物(从另一个数据库生成):
<column name="LAST_MOD_TIME" valueDate="2009-05-30T00:39:40"/>
当我使用mvn liquibase:update
运行此文件时它会产生如下错误:
[失败的SQL:INSERT INTO ....,不支持:2009-05-30T00:39:40]
删除T
没有区别。唯一有效的方法是将其与HH:MI:SS
值完全分开。
我尝试在Oracle中更改会话NLS_DATE_FORMAT
-但这可能需要在整个系统范围内进行,但我尚未弄清。或以某种方式将其添加到Liquibase更改文件中。
任何帮助表示赞赏。
堆栈跟踪:
org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目liquibase.ecom上执行目标org.liquibase:liquibase-maven-plugin:3.6.1:update(default-cli):设置或运行Liquibase时出错:变更集src / main / resources / liquibase / db-prop-changelog-4.xml :: 1531127783280-4 :: user的迁移失败: 原因:liquibase.exception.DatabaseException:ORA-00917:缺少逗号
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:370)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
原因:liquibase.exception.MigrationFailedException:更改集src / main / resources / liquibase / db-ec-prop-changelog-4.xml :: 1531127783280-4 :: user的迁移失败: 原因:liquibase.exception.DatabaseException:ORA-00917:缺少逗号
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:637)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:78)
at liquibase.Liquibase.update(Liquibase.java:202)
at liquibase.Liquibase.update(Liquibase.java:179)
at liquibase.Liquibase.update(Liquibase.java:334)
at org.liquibase.maven.plugins.LiquibaseUpdate.doUpdate(LiquibaseUpdate.java:33)
at org.liquibase.maven.plugins.AbstractLiquibaseUpdateMojo.performLiquibaseTask(AbstractLiquibaseUpdateMojo.java:30)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:366)
... 21 more
原因:liquibase.exception.DatabaseException:ORA-00917:缺少逗号 [失败的SQL:将属性(OBJECT_ID,名称,位置,值,描述,INSERT_DATE_TIME,LAST_MOD_TIME,LAST_MODIFIED_BY,LAST_ACCESS_AUDIT_TIME,VERSION,ENVIRONMENT_NAME)插入属性(60471,'INFORMATION','INFORMATION',' UNSUPUPED:2018-05-30T00:39:40,UNSUPPORTED:2018-05-30T00:39:40,'abc',UNSUPPORTED:2018-05-30T00:39:40,1,NULL)] 在liquibase.executor.jvm.JdbcExecutor $ ExecuteStatementCallback.doInStatement(JdbcExecutor.java:356) 在liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57) 在liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125) 在liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229) 在liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211) 在liquibase.changelog.ChangeSet.execute(ChangeSet.java:600) ...还有29个
at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
答案 0 :(得分:0)
我不知道Liquibase会如何处理,但是Oracle支持ISO SQL Date & TIMESTAMP literals:
日期时间文字
Oracle数据库支持四种日期时间数据类型:DATE,TIMESTAMP, 带有时区的时间戳和带有本地时区的时间戳。
DATE '1998-12-25'
答案 1 :(得分:0)
最后,我发现的唯一方法是:
添加触发器,如下所示:
CREATE OR REPLACE TRIGGER LOGINTRG
2 AFTER LOGON ON DATABASE
3 BEGIN
4 EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT=''YYYY-MM-DD"T"HH24:MI:SS''';
5 END LOGINTRG;
6 /
和
在插入中将valueDate更改为value(注意:此changelog是使用generateLog选项从现有的oracle数据库生成的。)
<insert tableName="MY_TABLE">
<!--column name="INSERT_DATE_TIME" valueDate="2009-05-30T00:39:40"/-->
<column name="INSERT_DATE_TIME" value="2009-05-30T00:39:40"/>
..
..