Informatica中{Date}数据类型的问题

时间:2016-04-26 22:34:54

标签: java etl informatica-powercenter

我创建了一个可重用的转换,其中我有一个日期/时间格式的输入端口。

现在当我在我的java代码中使用这个日期/时间端口时,它给了我不兼容的错误长/日期。

所以我将java转换的输入端口改为String,并在java转换中使用了这个字符串变量。但即使这段代码也给我一个错误。

Severity    Timestamp   Node    Thread  Message Code    Message
INFO    26-04-2016 16:55:30 node01_Gizmo    READER_1_1_1    RR_4049 RR_4049 SQL Query issued to database : (Tue Apr 26 16:55:30 2016)
INFO    26-04-2016 16:55:30 node01_Gizmo    READER_1_1_1    RR_4050 RR_4050 First row returned from database to reader : (Tue Apr 26 16:55:30 2016)
INFO    26-04-2016 16:55:30 node01_Gizmo    READER_1_1_1    BLKR_16019  Read [10] rows, read [0] error rows for source table [CUSTOMERS] instance name [CUSTOMERS]
INFO    26-04-2016 16:55:30 node01_Gizmo    READER_1_1_1    BLKR_16008  Reader run completed.
INFO    26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JAVA PLUGIN_1762    [DEBUG] Unparseable using java.text.SimpleDateFormat@9586200
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JTX_1005    [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
INFO    26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JTX_1015    [DEBUG] Exception thrown from Java transformation: [Column name [05/06/1998 00:00:00.000000] is invalid.].
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JAVA PLUGIN_1762    [ERROR] Column name [05/06/1998 00:00:00.000000] is invalid.
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JAVA PLUGIN_1762    [ERROR]     at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplFixed.isNull(JTXPartitionDriverImplFixed.java:737)
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    JAVA PLUGIN_1762    [ERROR]     at com.informatica.powercenter.server.jtx.JTXPartitionDriverImplGen.execute(JTXPartitionDriverImplGen.java:223)
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    TM_6085 A fatal error occurred at  transformation [DateFormat], and the session is terminating. 
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    TM_6085 A fatal error occurred at  transformation [SQ_CUSTOMERS], and the session is terminating. 
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    TM_6085 A fatal error occurred at  transformation [SQ_CUSTOMERS], and the session is terminating. 
ERROR   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    TM_6085 A fatal error occurred at  transformation [SQ_CUSTOMERS], and the session is terminating. 
DEBUG   26-04-2016 16:55:30 node01_Gizmo    TRANSF_1_1_1    DBG_21511   TE: Fatal Transformation Error.
INFO    26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8167    Start loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO    26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8333    Rolling back all the targets due to fatal session error.
ERROR   26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8170    Writer run terminated: Abort Session request received from the DTM
INFO    26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8168    End loading table [DateFormat] at: Tue Apr 26 16:55:30 2016
INFO    26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8035    Load complete time: Tue Apr 26 16:55:30 2016

LOAD SUMMARY
============

WRT_8036 Target: DateFormat (Instance Name: [DateFormat1])
WRT_8044 No data loaded for this target



INFO    26-04-2016 16:55:30 node01_Gizmo    WRITER_1_*_1    WRT_8043    *****END LOAD SESSION*****

Day是String类型的输出端口。以下是java转换中使用的代码:

SimpleDateFormat formatter;
formatter = new SimpleDateFormat("dd-MM-yyyy");
Date my_date = null;
try{
    my_date = formatter.parse(Inp_Date);
}
catch(Exception e) { 
          System.out.println("Unparseable using " + formatter); 
      }
    formatter = new SimpleDateFormat("d");
    Day=formatter.format(my_date);

请告诉我如何在java转换中使用日期/时间变量。

此致 地塞米松。

1 个答案:

答案 0 :(得分:0)

您应该使用带有TO_CHAR(inp_Date,'dd')表达式的表达式转换来进行此类转换。

在Java代码中,格式字符串(dd-MM-yyyy)与输入日期格式(05/06/1998 00:00:00.000000)不匹配。它可能应该改为这样:

formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSSSSS");