CAN WE USE DECODE FUNCTION

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ravindrag
Participant
Posts: 40
Joined: Wed Dec 14, 2005 3:22 am

CAN WE USE DECODE FUNCTION

Post by ravindrag »

hi

i want to know can we use decode function in datastage . are any other functions similar to decode
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

There are hundreds of different "decode" functions out there in the programming world. Which one are you referring to?
ravindrag
Participant
Posts: 40
Joined: Wed Dec 14, 2005 3:22 am

Post by ravindrag »

i want to decode for a column like below

DECODE ( CONST_NAME
'Five', 5,
'six', 6,
'seven', 7,
'ten', )
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

There is no DECODE function like that built into DataStage. There are various ways of doing this starting with a long IF-THEN-ELSE or a CASE statement. How you solve this depends upon what your primary objectives are - simplicity or performance.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In a server job the most efficient mechanism is to use a Hashed File stage servicing the reference input link of a Transformer stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Ray - not for a DECODE with only 4 values; that would be a lot of overhead. an IF-THEN-ELSE... construct or {my preference} a INDEX/LOCATE statement is going to be faster than a cached hash lookup. If there are tens or hundreds of lookups then that would be a different matter.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Hmm... as with most things, 'depends'. Another consideration would be the nature of the decoded data. If you have a static, fixed, never will change list then you've covered all the considerations. If there is a possibility that it could change, I'd look into storing the decode data in a flat file and sourcing it into a cached hashed file in the job each run. That way you don't have to touch the job to add a new decode value pair. And unless you are doing a bajillion lookups, I wouldn't be too concerned about the 'overhead' it adds to the job. :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 »

I'd still use a hashed file, even for four rows. Might even populate it with an INSERT statement in ExecTCL before-stage subroutine in this case.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply