"Incompatible data type in operation" 尝试格式化日期时间时出错
"Incompatible data type in operation" Error when trying to format datetime
在 ODI 中,我从 MS SQL 服务器中的 table 获取字段 [datetime]。
来自 MS SQL 的日期时间格式如下:2019-06-26 07:41:00.000.
我需要将其转换为这种格式:26-06-2019 10:41:00 即 DD-MM-YYYY HH:MI:SS 小时 增加 3,然后写入 JSON 文件。
JSON中对应的字段为VARCHAR(string)。
但我收到错误:原因:java.sql.SQLSyntaxErrorException:操作中的数据类型不兼容
我在 ODI 12c 映射属性表达式编辑器中给出了以下表达式:
TO_CHAR(TO_DATE(NVL(SUBSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, 0, INSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, '.')-1),
L_MAILITM_EVENTS.EVENT_GMT_DT ),'YYYY-MM-DD HH24:MI:SS')+ 3/24,
'DD-MM-YYYY HH24:MI:SS')
整个错误:
ODI-1228: Task Insert new lines-IKM XML Control Append- fails on the
target connection IPSEvents_Array_Json. Caused By:
java.sql.SQLSyntaxErrorException: incompatible data type in operation
at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at
org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at
org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) at
org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source) at
com.sunopsis.jdbc.driver.xml.SnpsXmlStatementRedirector.execute(SnpsXmlStatementRedirector.java:77)
at
com.sunopsis.jdbc.driver.xml.SnpsXmlStatement.execute(SnpsXmlStatement.java:31)
at
oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:205)
at
oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:142)
at
oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:28)
at
oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:52)
at
oracle.odi.runtime.agent.execution.SessionTask.processTask(SessionTask.java:206)
at
oracle.odi.runtime.agent.execution.SessionTask.doExecuteTask(SessionTask.java:117)
at
oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:886)
at
oracle.odi.runtime.agent.execution.SessionExecutor$SerialTrain.runTasks(SessionExecutor.java:2225)
at
oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:610)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doAction(TaskExecutorAgentRequestProcessor.java:718)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doAction(TaskExecutorAgentRequestProcessor.java:611)
at
oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203)
at
oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800)
at
oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access00(StartSessRequestProcessor.java:74)
at
oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:702)
at
oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180)
at
oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor.run(DefaultAgentTaskExecutor.java:108)
at java.lang.Thread.run(Thread.java:748) Caused by:
org.hsqldb.HsqlException: incompatible data type in operation at
org.hsqldb.error.Error.error(Unknown Source) at
org.hsqldb.error.Error.error(Unknown Source) at
org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at
org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionLogical.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionOp.resolveTypesForCaseWhen(Unknown Source) at
org.hsqldb.ExpressionOp.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at
org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at
org.hsqldb.QuerySpecification.resolveExpressionTypes(Unknown Source)
at org.hsqldb.QuerySpecification.resolveTypesPartOne(Unknown Source)
at org.hsqldb.RangeVariable.resolveRangeTable(Unknown Source) at
org.hsqldb.QuerySpecification.resolveRangeVariables(Unknown Source)
at org.hsqldb.QuerySpecification.resolveReferences(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source) at
org.hsqldb.ParserDML.compileInsertStatement(Unknown Source) at
org.hsqldb.ParserCommand.compilePart(Unknown Source) at
org.hsqldb.ParserCommand.compileStatements(Unknown Source) at
org.hsqldb.Session.executeDirectStatement(Unknown Source) at
org.hsqldb.Session.execute(Unknown Source) ... 22 more
我哪里错了?
由于目标是文件,所以不是Oracle数据库在做转换,而是ODI Studio或ODI代理的内部HSQL数据库。这里不能使用Oracle函数,可以用HSQL函数代替。以下是可用的函数:http://hsqldb.org/doc/guide/builtinfunctions-chapt.html.
或者,可以在 L_MAILITM_EVENTS 数据存储之后的映射中添加一个表达式,以使用 MS SQL 特定函数对源数据库进行转换。这会将在 MS SQL 上执行的 SELECT 语句更改为直接应用函数。确保将表达式的执行位置更改为源。
在 ODI 中,我从 MS SQL 服务器中的 table 获取字段 [datetime]。 来自 MS SQL 的日期时间格式如下:2019-06-26 07:41:00.000.
我需要将其转换为这种格式:26-06-2019 10:41:00 即 DD-MM-YYYY HH:MI:SS 小时 增加 3,然后写入 JSON 文件。
JSON中对应的字段为VARCHAR(string)。
但我收到错误:原因:java.sql.SQLSyntaxErrorException:操作中的数据类型不兼容
我在 ODI 12c 映射属性表达式编辑器中给出了以下表达式:
TO_CHAR(TO_DATE(NVL(SUBSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, 0, INSTR(L_MAILITM_EVENTS.EVENT_GMT_DT, '.')-1),
L_MAILITM_EVENTS.EVENT_GMT_DT ),'YYYY-MM-DD HH24:MI:SS')+ 3/24,
'DD-MM-YYYY HH24:MI:SS')
整个错误:
ODI-1228: Task Insert new lines-IKM XML Control Append- fails on the target connection IPSEvents_Array_Json. Caused By: java.sql.SQLSyntaxErrorException: incompatible data type in operation at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source) at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source) at com.sunopsis.jdbc.driver.xml.SnpsXmlStatementRedirector.execute(SnpsXmlStatementRedirector.java:77) at com.sunopsis.jdbc.driver.xml.SnpsXmlStatement.execute(SnpsXmlStatement.java:31) at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:205) at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:142) at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:28) at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:52) at oracle.odi.runtime.agent.execution.SessionTask.processTask(SessionTask.java:206) at oracle.odi.runtime.agent.execution.SessionTask.doExecuteTask(SessionTask.java:117) at oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:886) at oracle.odi.runtime.agent.execution.SessionExecutor$SerialTrain.runTasks(SessionExecutor.java:2225) at oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:610) at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doAction(TaskExecutorAgentRequestProcessor.java:718) at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doAction(TaskExecutorAgentRequestProcessor.java:611) at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203) at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800) at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access00(StartSessRequestProcessor.java:74) at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:702) at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180) at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor.run(DefaultAgentTaskExecutor.java:108) at java.lang.Thread.run(Thread.java:748) Caused by: org.hsqldb.HsqlException: incompatible data type in operation at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.error.Error.error(Unknown Source) at org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at org.hsqldb.FunctionSQL.resolveTypes(Unknown Source) at org.hsqldb.ExpressionLogical.resolveTypes(Unknown Source) at org.hsqldb.ExpressionOp.resolveTypesForCaseWhen(Unknown Source) at org.hsqldb.ExpressionOp.resolveTypes(Unknown Source) at org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at org.hsqldb.ExpressionArithmetic.resolveTypes(Unknown Source) at org.hsqldb.FunctionCustom.resolveTypes(Unknown Source) at org.hsqldb.QuerySpecification.resolveExpressionTypes(Unknown Source) at org.hsqldb.QuerySpecification.resolveTypesPartOne(Unknown Source) at org.hsqldb.RangeVariable.resolveRangeTable(Unknown Source) at org.hsqldb.QuerySpecification.resolveRangeVariables(Unknown Source) at org.hsqldb.QuerySpecification.resolveReferences(Unknown Source) at org.hsqldb.QueryExpression.resolve(Unknown Source) at org.hsqldb.ParserDML.compileInsertStatement(Unknown Source) at org.hsqldb.ParserCommand.compilePart(Unknown Source) at org.hsqldb.ParserCommand.compileStatements(Unknown Source) at org.hsqldb.Session.executeDirectStatement(Unknown Source) at org.hsqldb.Session.execute(Unknown Source) ... 22 more
我哪里错了?
由于目标是文件,所以不是Oracle数据库在做转换,而是ODI Studio或ODI代理的内部HSQL数据库。这里不能使用Oracle函数,可以用HSQL函数代替。以下是可用的函数:http://hsqldb.org/doc/guide/builtinfunctions-chapt.html.
或者,可以在 L_MAILITM_EVENTS 数据存储之后的映射中添加一个表达式,以使用 MS SQL 特定函数对源数据库进行转换。这会将在 MS SQL 上执行的 SELECT 语句更改为直接应用函数。确保将表达式的执行位置更改为源。