two type conversions in one derivation

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pattemk
Participant
Posts: 84
Joined: Wed May 16, 2007 4:04 pm

two type conversions in one derivation

Post by pattemk »

Hi,

Iam trying to put something like below if then else condition in the derivation grid of my transformer.

If TRIM(DSLink219.COL5) = 'DATE' Then StringToDate(DSLink219.FIELD5,"%yyyy-%mm-%dd") Else StringToTimestamp(DSLink219.FIELD5,"%yyyy-%mm-%dd %hh:%nn:%ss")

I am getting the following compilation error, "Error in output column derivation expression for column FIELD5 in link DSLink232. Invalid conversion requested from a timestamp to a date."

I think it is not the proper way to two kinds of type conversions in one derivation but is there any other way of achieving the abvoce condition using one transformer.

Please advice
prasannakumarkk
Participant
Posts: 117
Joined: Wed Feb 06, 2013 9:24 am
Location: Chennai,TN, India

Post by prasannakumarkk »

What is the target data type?

Guess you are trying acheive this?

Code: Select all

StringToTimestamp((If TRIM(DSLink219.COL5) = 'DATE' Then DSLink219.FIELD5 || "00:00:00" Else DSLink219.FIELD5),"%yyyy-%mm-%dd %hh:%nn:%ss") 
Thanks,
Prasanna
pattemk
Participant
Posts: 84
Joined: Wed May 16, 2007 4:04 pm

Post by pattemk »

Thanks for replying, but the target metadata will be date if the COL5 = 'DATE' and will be timestamp otherwise.


PLease advice
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

A column cannot have two different datatypes. Either its a DATE or TIMESTAMP.
Thanx and Regards,
ETL User
harishkumar.upadrasta
Participant
Posts: 18
Joined: Tue Dec 25, 2012 10:39 pm
Location: Detroit,MI

Post by harishkumar.upadrasta »

Please convert it either to Date/ Timestamp depending on Target Data type. A column can have a single data type.
Harish
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Post by BI-RMA »

If, however, You are sending the conversion-result down to different targets with different datatypes, use two different columns for the derivation, even if the column-names happen to be identical in both targets (which is not a good practice, though).
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I agree with Prasanna's solution. For whatever that is worth. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

... except, of course, for the incorrect concatenation operator. ;)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well yah... duh. :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
prasannakumarkk
Participant
Posts: 117
Joined: Wed Feb 06, 2013 9:24 am
Location: Chennai,TN, India

Post by prasannakumarkk »

Oops :) . regret team.
Thanks,
Prasanna
Post Reply