Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-5429

timestampadd(SQL_TSI_MONTH, 1, 31/03/2018)) results in ORA-01839: date not valid for month specified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 11.1, 11.0.1, 10.3.3
    • 11.x
    • Query Engine
    • None
    • Hide

      1.
      Use model bound to Oracle's HR schema

      <model name="oracle_DB">
              <property name="importer.useFullSchemaName" value="true"/>
      	<property name="importer.tableTypes" value="TABLE,VIEW"/>
              <property name="importer.schemaPattern" value="HR"/>
              <source name="oracleDB" translator-name="oracle" connection-jndi-name="java:/OracleHRDS"/>
          </model>
      

      2.
      In Squirrel execute query

      select hire_date, timestampadd(SQL_TSI_MONTH, 11, hire_date) from HR.employees where employee_id = 153
      

      3.

      See the stacktrace

      2018-07-22 16:04:33,853 WARN  [org.teiid.CONNECTOR] (Worker20_QueryProcessorQueue129) L49HpqbmzfA/ Connector worker process failed for atomic-request=L49HpqbmzfA/.43.0.29: org.teiid.translator.jdbc.JDBCExecutionException: 1839 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: [] SQL: SELECT g_0."HIRE_DATE", g_0."HIRE_DATE" + (INTERVAL '11' MONTH(2)) FROM "HR"."EMPLOYEES" g_0 WHERE g_0."EMPLOYEE_ID" = 153]
      	at org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:127)
      	at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:382)
      	at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:229)
      	at com.sun.proxy.$Proxy36.execute(Unknown Source)
      	at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:302)
      	at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108)
      	at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:104)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:61)
      	at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:277)
      	at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:115)
      	at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:206)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: java.sql.SQLDataException: ORA-01839: date not valid for month specified
      
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439)
      	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395)
      	at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802)
      	at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436)
      	at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
      	at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521)
      	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205)
      	at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861)
      	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145)
      	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267)
      	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449)
      	at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3493)
      	at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
      	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
      	at org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:119)
      	... 17 more
      
      Show
      1. Use model bound to Oracle's HR schema <model name= "oracle_DB" > <property name= "importer.useFullSchemaName" value= "true" /> <property name= "importer.tableTypes" value= "TABLE,VIEW" /> <property name= "importer.schemaPattern" value= "HR" /> <source name= "oracleDB" translator-name= "oracle" connection-jndi-name= "java:/OracleHRDS" /> </model> 2. In Squirrel execute query select hire_date, timestampadd(SQL_TSI_MONTH, 11, hire_date) from HR.employees where employee_id = 153 3. See the stacktrace 2018-07-22 16:04:33,853 WARN [org.teiid.CONNECTOR] (Worker20_QueryProcessorQueue129) L49HpqbmzfA/ Connector worker process failed for atomic-request=L49HpqbmzfA/.43.0.29: org.teiid.translator.jdbc.JDBCExecutionException: 1839 TEIID11008:TEIID11004 Error executing statement(s): [Prepared Values: [] SQL: SELECT g_0."HIRE_DATE", g_0."HIRE_DATE" + (INTERVAL '11' MONTH(2)) FROM "HR"."EMPLOYEES" g_0 WHERE g_0."EMPLOYEE_ID" = 153] at org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:127) at org.teiid.dqp.internal.datamgr.ConnectorWorkItem.execute(ConnectorWorkItem.java:382) at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.teiid.dqp.internal.datamgr.ConnectorManager$1.invoke(ConnectorManager.java:229) at com.sun.proxy.$Proxy36.execute(Unknown Source) at org.teiid.dqp.internal.process.DataTierTupleSource.getResults(DataTierTupleSource.java:302) at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:108) at org.teiid.dqp.internal.process.DataTierTupleSource$1.call(DataTierTupleSource.java:104) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.teiid.dqp.internal.process.FutureWork.run(FutureWork.java:61) at org.teiid.dqp.internal.process.DQPWorkContext.runInContext(DQPWorkContext.java:277) at org.teiid.dqp.internal.process.ThreadReuseExecutor$RunnableWrapper.run(ThreadReuseExecutor.java:115) at org.teiid.dqp.internal.process.ThreadReuseExecutor$3.run(ThreadReuseExecutor.java:206) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.sql.SQLDataException: ORA-01839: date not valid for month specified at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:439) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:395) at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:802) at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:436) at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186) at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:521) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:205) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:861) at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1145) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1267) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3449) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3493) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491) at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504) at org.teiid.translator.jdbc.JDBCQueryExecution.execute(JDBCQueryExecution.java:119) ... 17 more

      There is a known problem with Oracle's intervals:

      select to_date('2018/03/31', 'yyyy/mm/dd') + (INTERVAL '1' MONTH(2)) from dual
      

      results in ORA-01839: date not valid for month specified error
      As an alternative, ADD_MONTHS function could be used .

      select ADD_MONTHS(to_date('2018/03/31', 'yyyy/mm/dd'), 1) from dual
      

      It is not defined in the functions spec how timestampadd with SQL_TSI_MONTH should behave in some cases but anyway no error should happen.

      Currently "interval" - inflicted Oracle errors are transmitted for timestampadd invocations.

              rhn-engineering-shawkins Steven Hawkins
              isemenov_jira Ivan Semenov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: