Marthin
Marthin

Reputation: 6543

invalid character when running liquibase script

When I run the script below in Sql Developer it correctly creates my global temporary table but when I run my liquibase script it fails because of "invalid character". Anyone know why this fails?

In Sql Developer (works)

 CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;

Liquibase xml (fails with below stacktrace)

<changeSet id="createGlobalTemporaryTableForTransactionsMove" author="me" >
    <preConditions onFail="MARK_RAN">
        <not>
            <tableExists tableName="TransactionsToMove"/>
        </not>
    </preConditions>
    <sql splitStatements="false" endDelimiter=";"><![CDATA[              
      CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
          TransactionId NUMBER(38,0) NOT NULL,
          PRIMARY KEY (TransactionId))
          ON COMMIT DELETE ROWS;
    ]]>
    </sql>
</changeSet>

Stacktrace

    SEVERE 2013-11-14 09:10:liquibase: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;
java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
SEVERE 2013-11-14 09:10:liquibase: Change Set db/scripts/movetohistorical-oracleserver.xml::createGlobalTemporaryTableForTransactionsMove::marbe failed.  Error: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        ... 11 more
INFO 2013-11-14 09:10:liquibase: Successfully released change log lock
Exception in thread "main" se.mypackage.exbo.database.DatabaseManagerException: Liquibase changelog update failed using changelog: db-main-create-13.4.xml, reason: Migration failed for change set db/scripts/movetohistorical-oraclese
     Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: ORA-00911: invalid character

        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:180)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.create(LiquibaseDatabaseManager.java:145)
        at se.mypackage.exbo.database.DatabaseManager.dropAndCreate(DatabaseManager.java:349)
        at se.mypackage.exbo.database.DatabaseManager.main(DatabaseManager.java:720)
Caused by: liquibase.exception.MigrationFailedException: Migration failed for change set db/scripts/movetohistorical-oracleserver.xml::createGlobalTemporaryTableForTransactionsMove::marbe:
     Reason: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character
:
          Caused By: ORA-00911: invalid character

        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:347)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:27)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:58)
        at liquibase.Liquibase.update(Liquibase.java:113)
        at se.mypackage.exbo.database.liquibase.LiquibaseDatabaseManager.runChangelog(LiquibaseDatabaseManager.java:177)
        ... 3 more
Caused by: liquibase.exception.DatabaseException: Error executing SQL CREATE GLOBAL TEMPORARY TABLE TransactionsToMove(
              TransactionId NUMBER(38,0) NOT NULL,
              PRIMARY KEY (TransactionId))
              ON COMMIT DELETE ROWS;: ORA-00911: invalid character

        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:105)
        at liquibase.database.AbstractDatabase.execute(AbstractDatabase.java:1014)
        at liquibase.database.AbstractDatabase.executeStatements(AbstractDatabase.java:998)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:317)
        ... 7 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:450)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:192)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1033)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1329)
        at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1909)
        at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1871)
        at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:318)
        at liquibase.executor.jvm.JdbcExecutor$1ExecuteStatementCallback.doInStatement(JdbcExecutor.java:92)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        ... 11 more

Upvotes: 6

Views: 7742

Answers (2)

Witold Kaczurba
Witold Kaczurba

Reputation: 10505

Clearly: DROP SEMICOLONS from Liquibase

Semicolons are not tolerated properly with Liquibase. SQL Developer expects you to use semicolons. Copying-pasting statments from one to the other will get you into trouble.

Some attempts of explaining can be found on the the web e.g: http://forum.liquibase.org/topic/formatted-sql-enddelimiter-issue

It is worth noticing that Oracle themselves have different approach to semicolons: SQL*Plus commands do not need to be termianted with semicolon; whereas statements are supposed to.

Upvotes: 0

Marco Baldelli
Marco Baldelli

Reputation: 3728

The semicolon is a command terminator used in client-side applications such as Oracle SQL*Plus.

Is is usually not needed when invoking a db command through a Prepared Statement or a similar technology.

Upvotes: 10

Related Questions