简体   繁体   English

Informatica中日期数据类型的问题

[英]Issue with datatype of Date in Informatica

I created a reusable transformation in which I have an input port of date/time format. 我创建了一个可重用的转换,其中有一个日期/时间格式的输入端口。

Now when I use this date/time port in my java code it gives me incompatible error long/date. 现在,当我在Java代码中使用此日期/时间端口时,它给了我不兼容的错误long / date。

So I changed the input port of java transformation to String and used this string variable in java transformation. 因此,我将java转换的输入端口更改为String,并在java转换中使用了此字符串变量。 But even this code is giving me an error. 但是,即使这段代码也给了我一个错误。

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 is an output port of type String. Day是String类型的输出端口。 The below is the code used in java transformation: 以下是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);

Please let me know how to use date/time variable in java transformation. 请让我知道如何在java转换中使用日期/时间变量。

Regards, Dex. 问候,敏捷。

You should use an expression transformation with the expression TO_CHAR(inp_Date,'dd') to do such conversions. 您应该使用带有表达式TO_CHAR(inp_Date,'dd')的表达式TO_CHAR(inp_Date,'dd')来进行此类转换。

In your Java code the format string (dd-MM-yyyy) does not match the input date format (05/06/1998 00:00:00.000000). 在您的Java代码中,格式字符串(dd-MM-yyyy)与输入日期格式(05/06/1998 00:00:00.000000)不匹配。 It should probably be changed to something like this: 应该将其更改为以下内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM