以下是查询。
从tablex中选择*,其中c_trans_date> =(选择 CONVERT(DATETIME,CONCAT(1, ' - ',(子串( '$ {SHORT_FILENAME}',CHARINDEX( '$ {SHORT_FILENAME} '1)-5,3)),'。' ' - ',子串( '$ {SHORT_FILENAME}',CHARINDEX( ' '' $ {SHORT_FILENAME}',1)-2,2-)),121)) 和c_trans_date< =(选择CONVERT(DATETIME,dateadd(day,-1,(select) DATEADD(月,1,(选择 的concat(1, ' - ' ' '(子串( '$ {SHORT_FILENAME}',CHARINDEX(' $ {SHORT_FILENAME}',1)-5,3)), ' - ',子串( ' ' '$ {SHORT_FILENAME}',CHARINDEX(' $ {SHORT_FILENAME}',1)-2,2-)))))),121))
错误说
2017/08/18 10:25:54 - Spoon - Transformation opened.
2017/08/18 10:25:54 - Spoon - Launching transformation [STATEX_DATA_PULL]...
2017/08/18 10:25:54 - Spoon - Started the transformation execution.
2017/08/18 10:25:54 - STATEX_DATA_PULL - Dispatching started for transformation [STATEX_DATA_PULL]
2017/08/18 10:25:54 - Input table.0 - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Unexpected error
2017/08/18 10:25:54 - Input table.0 - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : org.pentaho.di.core.exception.KettleDatabaseException:
2017/08/18 10:25:54 - Input table.0 - Couldn't get row from result set
2017/08/18 10:25:54 - Input table.0 - Conversion failed when converting date and/or time from character string.
2017/08/18 10:25:54 - Input table.0 -
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.core.database.Database.getRow(Database.java:2374)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.core.database.Database.getRow(Database.java:2344)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.core.database.Database.getRow(Database.java:2322)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.trans.steps.tableinput.TableInput.doQuery(TableInput.java:247)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.trans.steps.tableinput.TableInput.processRow(TableInput.java:138)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2017/08/18 10:25:54 - Input table.0 - at java.lang.Thread.run(Unknown Source)
2017/08/18 10:25:54 - Input table.0 - Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting date and/or time from character string.
2017/08/18 10:25:54 - Input table.0 - at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)
2017/08/18 10:25:54 - Input table.0 - at com.microsoft.sqlserver.jdbc.SQLServerResultSet$FetchBuffer.nextRow(SQLServerResultSet.java:4853)
2017/08/18 10:25:54 - Input table.0 - at com.microsoft.sqlserver.jdbc.SQLServerResultSet.fetchBufferNext(SQLServerResultSet.java:1781)
2017/08/18 10:25:54 - Input table.0 - at com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(SQLServerResultSet.java:1034)
2017/08/18 10:25:54 - Input table.0 - at org.pentaho.di.core.database.Database.getRow(Database.java:2362)
2017/08/18 10:25:54 - Input table.0 - ... 6 more
2017/08/18 10:25:54 - Input table.0 - Finished reading query, closing connection.
2017/08/18 10:25:54 - Input table.0 - Finished processing (I=0, O=0, R=0, W=0, U=0, E=1)
2017/08/18 10:25:54 - STATEX_DATA_PULL - Transformation detected one or more steps with errors.
2017/08/18 10:25:54 - STATEX_DATA_PULL - Transformation is killing the other steps!
2017/08/18 10:25:54 - STATEX_DATA_PULL - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Errors detected!
2017/08/18 10:25:54 - Spoon - The transformation has finished!!
2017/08/18 10:25:54 - STATEX_DATA_PULL - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Errors detected!
2017/08/18 10:25:54 - STATEX_DATA_PULL - ERROR (version 6.1.0.1-196, build 1 from 2016-04-07 12.08.49 by buildguy) : Errors detected!
BTW,它在SQLServer中执行查询时工作正常。
答案 0 :(得分:1)
Ahhrggg ......哦不...请Nooooo ... DateTimeFormat在MS服务器中运行但在PDI中运行...不是那个......不再......
首先检查Enable Lazy Conversion
步骤中的Input Table
复选框是否已开启。
如果问题仍然存在,您可以尝试编辑连接。在左侧面板中,选择Advanced
,然后选中/取消选中Support timestamp data type
。
如果问题仍然存在,那么你必须找出问题所在。使用SELECT *阅读表格并尝试使用Select Value
/ Metadata
步骤转换日期并使用格式播放。
如果仍然无法找到错误,请尝试以更多PDI样式解决问题,而不是在一个sql中解决问题。据我了解,数据格式取决于${SHORT_FILENAME}
,因此您可以将该变量用于Switch/Case
到相应的Select Value
/ Metadata
/ Date Format
,并在相应的Lookups
和Filter Rows
中迁移您的子选择。 [并且请在抱怨性能不好之前让我帮忙进行测试]。