Decode function

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
srini.dw
Premium Member
Premium Member
Posts: 186
Joined: Fri Aug 18, 2006 1:59 am
Location: Chennai

Decode function

Post by srini.dw »

Hi,

DECODE(job.empl_status, 'D', TO_CHAR(NVL(pers.dt_of_death,job.effdt),'MMDDYYYY') ) Descease_Date,

Iam supposed to do the above function in datastage, plz let me know if it is correct or not which is shown below?? Iam doing this in transformer

If job.empl_status < > 'D' Then
NULL
ElsIf job.empl_status = 'D' then
pers.dt_of_death
ElsIf job.empl_status Isnull then
job.effdt
End if

Thanks
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Check for null first. There is no ElsIf and there is no End If. Generate null using the SetNull() function - there is no "NULL constant".

Code: Select all

If IsNull(job.empl_status) Then job.effdt Else If job.empl_status = 'D' Then pers.dt_of_death Else SetNull()
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sudhakar_viswa
Participant
Posts: 85
Joined: Fri Nov 18, 2005 5:35 am

Post by sudhakar_viswa »

Hi,

If IsNull(job.empl_status) Then
SetNull()
Else If job.empl_status="D" Then
If IsNull(pers.dt_of_death) Then
DateToString(job.effdt,"MMDDYYYY")
Else DateToString(pers.dt_of_death,"MMDDYYYY")
Else SetNull()

If job and pers are not link names then you need to add the link names for all the columns specified above with "." seperator.

Regards,
-- sudhakar
i need to know datastage
sudhakar_viswa
Participant
Posts: 85
Joined: Fri Nov 18, 2005 5:35 am

Post by sudhakar_viswa »

Hi,

I forgot to specify % in date format.

If IsNull(job.empl_status) Then
SetNull()
Else If job.empl_status="D" Then
If IsNull(pers.dt_of_death) Then
DateToString(job.effdt,"%mm%dd%yyyy")
Else DateToString(pers.dt_of_death,"%mm%dd%yyyy")
Else SetNull()

Regards,
-- sudhakar
i need to know datastage
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:? Why DateToString()? There's nothing in the (implied) original specification that specifies a string type to be output - everything there suggests that the output column should be of type Date.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

He might have got confused with the "TO_CHAR" mask.
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Post Reply