Page 1 of 2

NULL Handling Issue

Posted: Tue Jul 13, 2010 2:45 pm
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.

Posted: Tue Jul 13, 2010 2:59 pm
by anbu
What is your source?

Try this

Code: Select all

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

Posted: Tue Jul 13, 2010 3:16 pm
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.

Posted: Tue Jul 13, 2010 3:18 pm
by anbu
What is your source? File or Table?

Posted: Tue Jul 13, 2010 3:20 pm
by highpoint
anbu wrote:What is your source? File or Table?
Source is a table

Posted: Tue Jul 13, 2010 8:08 pm
by highpoint
anbu wrote:What is your source? File or Table?

Appreciate help on this from professionals

Posted: Tue Jul 13, 2010 8:26 pm
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.

Posted: Tue Jul 13, 2010 9:22 pm
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.

Posted: Tue Jul 13, 2010 9:57 pm
by ray.wurlod
Do these columns have default values defined at any point in the processing?

Posted: Wed Jul 14, 2010 4:40 am
by Shaanpriya
The irrelevant result must be due to blank spaces.

Try using

If NullToEmpty(col1) = trim(col1) then '' else col1

Posted: Wed Jul 14, 2010 7:37 am
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.

Posted: Thu Jul 15, 2010 8:22 am
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.

Posted: Thu Jul 15, 2010 9:27 am
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.

Posted: Mon Jul 19, 2010 10:40 am
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.

Posted: Mon Jul 19, 2010 2:19 pm
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.