NULL Handling Issue

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

highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

NULL Handling Issue

Post by highpoint »

Hi

I have source decimal column as col1.

1st transformer:

Code: Select all

If isnull(col1) then '' else col1
When i see in the dataset after 1st transformer for the NULL values the col has all 0000000000000

In 2nd Transformer:

Code: Select all

If col= 1  Then 'Y' Else If col= 0  Then 'N' Else ''

Source is a decimal column.
Target is varchar.

But the problem is the output i am getting is 'N' even though the source is NULL.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

What is your source?

Try this

Code: Select all

If isnull(col1) Or trim(col1) = '' then '' else col1
You are the creator of your destiny - Swami Vivekananda
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

anbu wrote:What is your source?

Try this

Code: Select all

If isnull(col1) Or trim(col1) = '' then '' else col1

Nope this doesn't help.
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

What is your source? File or Table?
You are the creator of your destiny - Swami Vivekananda
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

anbu wrote:What is your source? File or Table?
Source is a table
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

anbu wrote:What is your source? File or Table?

Appreciate help on this from professionals
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Decimal data type is always converted to string (including in View Data) with leading and trailing non-significant zeroes. If you don't want them, you have to get rid of them, typically using a Trim() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

ray.wurlod wrote:Decimal data type is always converted to string (including in View Data) with leading and trailing non-significant zeroes. If you don't want them, you have to get rid of them, typically using a Trim() function.
Thanks Ray Wurlod.

But i still dont understand the following:

When my source field is Null. Why i am getting output as 'N' instead of getting ''(Nothing) in my target table after 2 transformers.

1st Transformer:
If isnull(col1) then '' else col1

2nd Transformer
If col= 1 Then 'Y' Else If col= 0 Then 'N' Else ''

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

Post by ray.wurlod »

Do these columns have default values defined at any point in the processing?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Shaanpriya
Participant
Posts: 22
Joined: Thu Sep 11, 2008 11:47 pm
Location: Bangalore

Post by Shaanpriya »

The irrelevant result must be due to blank spaces.

Try using

If NullToEmpty(col1) = trim(col1) then '' else col1
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

seems like you are defaulting empty to a decimal field and thats why it is defaulting it to zero. Try varchar as datatype or default it to a decimal value or you can do intermediate calculations in stage variables.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

ray.wurlod wrote:Do these columns have default values defined at any point in the processing?
No this column doesnot have any default value.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If you go to your source stage, double-click on the number at the left of the column or right-mouse click and "edit row" and then see if that column might have a default value set.
highpoint
Premium Member
Premium Member
Posts: 123
Joined: Sat Jun 19, 2010 12:01 am
Location: Chicago

Post by highpoint »

ArndW wrote:If you go to your source stage, double-click on the number at the left of the column or right-mouse click and "edit row" and then see if that column might have a default value set.
I checked it doesn't have a default value set.
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Did you check your logs ? Maybe those records are dropped in the transformer due to datatype mismatch.

Also view the source data to ensure that they are NULL. Constraint the flow to about 10 records with different combination to check the result.

Use a new dataset - i.e. create rather than append.
Post Reply