concatenation of values with null

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
sujaoschin
Premium Member
Premium Member
Posts: 102
Joined: Tue Jan 31, 2006 4:13 am

concatenation of values with null

Post by sujaoschin »

I am doing concatenation of two column values if below condition is true

AB_GROUP has the value - 'switch'
AB_SUBGROUP has the value - NULL or empty

Condition
if Biseps_Genericcode.BISEPS_GENERICCODE = hash_Biseps_Genericcode.AB_CODE then hash_Biseps_Genericcode.AB_GROUP:" ":hash_Biseps_Genericcode.AB_SUBGROUP else @NULL

When I tried to concatenate for the above example for the true condition [ 'switch' with 'null' value] , I am getting the result of NULL in the output.

The output should be 'switch' . Why the output field got populated as blank?
Sujatha K
chitravallivenkat
Participant
Posts: 106
Joined: Thu Jun 08, 2006 8:51 am

Post by chitravallivenkat »

Whenever you concatenate value with NULL, always will be NULL. So do NULL check before concatenating, do as per requirement.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

AB_GROUP : NullToEmpty(AB_SUBGROUP)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sujaoschin
Premium Member
Premium Member
Posts: 102
Joined: Tue Jan 31, 2006 4:13 am

Post by sujaoschin »

Thank you. I have used the below expression and the problem is resolved.

if Biseps_Genericcode.BISEPS_GENERICCODE = hash_Biseps_Genericcode.AB_CODE AND not(isnull(hash_Biseps_Genericcode.AB_SUBGROUP)) then hash_Biseps_Genericcode.AB_GROUP:" ": hash_Biseps_Genericcode.AB_SUBGROUP else if Biseps_Genericcode.BISEPS_GENERICCODE = hash_Biseps_Genericcode.AB_CODE AND isnull(hash_Biseps_Genericcode.AB_SUBGROUP) then hash_Biseps_Genericcode.AB_GROUP else @NULL
Sujatha K
Post Reply