StringToDate on an empty string
Posted: Thu Jan 12, 2012 6:29 pm
The datastage job i am developing deals mostly with date columns.
The source columns are a char [8] fields. These fields stores dates in format 20100101 i.e. yyyymmdd
The job should should be able to handle all kind of junk data.
so when ever i am hitting null or invalid date in this field i make it empty '' string in the stage variable. My stage variables are varchar(10).
Then in next various other stage variables i compare this field with other fields like follows
The job fails or throws warning when it tries hit the empty '' string. It cannot convert '' empty from stringtoDate. Not sure how to handle this scenario
I get warning: Copy_of_Transformer_77,0: Conversion error calling conversion routine date_from_string data may have been lost
In some cases job fail with error: Copy_of_Transformer_77,0: Failure during execution of operator logic.
Appreciate help on how to handle this '' empty case scenario.
The source columns are a char [8] fields. These fields stores dates in format 20100101 i.e. yyyymmdd
The job should should be able to handle all kind of junk data.
so when ever i am hitting null or invalid date in this field i make it empty '' string in the stage variable. My stage variables are varchar(10).
Then in next various other stage variables i compare this field with other fields like follows
The job fails or throws warning when it tries hit the empty '' string. It cannot convert '' empty from stringtoDate. Not sure how to handle this scenario
Code: Select all
code:
If IsNotNull(orcl.dslink4.ORDER_DATE) and svOrderDate<>'' and StringToDate(svOrderDate,"%yyyy%mm%dd") < '2010-03-01'
Then
'ABC'
Else If StringToDate(svCancelDate,"%yyyy%mm%dd") < StringToDate(svOrderDate,"%yyyy%mm%dd")
Then
'DEF
Else If StringToDate(svCancelDate,"%yyyy%mm%dd") > StringToDate(svOrderDate,"%yyyy%mm%dd")
Then
'GHI'
Else
'XYZ'
In some cases job fail with error: Copy_of_Transformer_77,0: Failure during execution of operator logic.
Appreciate help on how to handle this '' empty case scenario.