0
votes

I have a column defined like so in my change set:

<column name="LAST_MOD_TIME" type="date"/>

I have an insert like this (generated from another database):

<column name="LAST_MOD_TIME" valueDate="2009-05-30T00:39:40"/>

When I run this using mvn liquibase:update

It generates an error like so:

[Failed SQL: INSERT INTO .... , UNSUPPORTED:2009-05-30T00:39:40]

Removing T makes no difference. The only thing that works is to remote that and the HH:MI:SS values altogether.

I tried alter session NLS_DATE_FORMAT in Oracle - but this might need to be system wide which I haven't figured out. Or somehow add this to the Liquibase change file.

Any help appreciated.

Stacktrace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.6.1:update (default-cli) on project liquibase.ecom: Error setting up or running Liquibase: Migration failed for change set src/main/resources/liquibase/db-prop-changelog-4.xml::1531127783280-4::user: Reason: liquibase.exception.DatabaseException: ORA-00917: missing comma

    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

Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set src/main/resources/liquibase/db-ec-prop-changelog-4.xml::1531127783280-4::user: Reason: liquibase.exception.DatabaseException: ORA-00917: missing comma

    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

Caused by: liquibase.exception.DatabaseException: ORA-00917: missing comma [Failed SQL: INSERT INTO PROPERTY (OBJECT_ID, NAME, LOCALE, VALUE, DESCRIPTION, INSERT_DATE_TIME, LAST_MOD_TIME, LAST_MODIFIED_BY, LAST_ACCESS_AUDIT_TIME, VERSION, ENVIRONMENT_NAME) VALUES (60471, 'INFORMATION', 'ie', 'Y', 'INFORMATION', UNSUPPORTED:2018-05-30T00:39:40, UNSUPPORTED:2018-05-30T00:39:40, 'abc', UNSUPPORTED:2018-05-30T00:39:40, 1, NULL)] at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:356) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:57) at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:125) at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1229) at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1211) at liquibase.changelog.ChangeSet.execute(ChangeSet.java:600) ... 29 more

    at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:494)
2
Can you show the complete error / stacktrace?Jens

2 Answers

0
votes

I do not know how is this handled by Liquibase but Oracle supports ISO SQL Date & TIMESTAMP literals:

Datetime Literals

Oracle Database supports four datetime datatypes: DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, and TIMESTAMP WITH LOCAL TIME ZONE.

DATE '1998-12-25'
0
votes

In the end the only way I found was to:

  1. Add a trigger like so:

    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  /
    

and

  1. Change valueDate to value in the insert (note: this changelog was generated from an existing oracle database, using the generateLog option).

    <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"/>
    ..
    ..