Page 1 of 2

Null handling in transformer

Posted: Fri May 29, 2009 7:10 am
by shalini11
Hi All,

In the transformer, I have given a condition for a column as:

If Trim(NullToEmpty(Col1))='' Then 'Unknown'
Else Trim(NullToEmpty(Col1))

But the records having Col1 as blank are getting rejected. I dont want to reject the record, rather replace it with "Unknown" if it is blank.

The same condition is working for other 3 columns but not with column.

Can you pls help.

Thanks

Posted: Fri May 29, 2009 7:21 am
by chulett
And 'blank' means what here, exactly?

Posted: Fri May 29, 2009 7:25 am
by shalini11
Blank means that the value is not present in the input file.The file is tab delimited

Posted: Fri May 29, 2009 1:58 pm
by ray.wurlod
Trim() will not remove all blank spaces, it will leave one. You may need to re-think your logic. For example

Code: Select all

NullToEmpty(Trim(InLink.TheField)) <= " "

Use another logic

Posted: Sat May 30, 2009 1:43 am
by sureshreddy2009
:oops:
Hi
as you said the file has a Tab delimiter then the sequential file in datastage extracts the data from the file, if any value in file contains null then use this funtion to handle null values in transformer, if your aim is to replace null with 'unknown' then use this funtion If IsNull(Column) then 'Unknown'

in another case, if the field contains empty that is 1 or more spaces then use this funtion
If IsNull(Trim(column)) then 'unknown'

Re: Use another logic

Posted: Sat May 30, 2009 11:29 pm
by naveen19
Hi,

You can use this in ur derivation part..

If IsNull(DsLink12.INPUT_COLUMN) Then 'UNKNOWN' Else If Len(TrimB(DsLink12.INPUT_COLUMN)) =0 Then 'UNKNOWN' Else DsLink12.INPUT_COLUMN

Regards...Naveen.K

Posted: Sun May 31, 2009 4:14 pm
by ray.wurlod
Ur was a city in ancient Babylon. The second person personal pronoun in English is spelled "your". Please maintain a professional standard of written English on DSXchange, which is used by many people whose first language is not English.

Posted: Sun May 31, 2009 9:18 pm
by shalini11
Sorry to say but none of the above solutions are working. The records are still getting rejected. The condition is working fine for other fields. Only 2 fields are creating problem.

Please suggest what to do.

Thanks

Posted: Sun May 31, 2009 9:45 pm
by preetiv
Hi,

What is the datatype of the column? Also, did you check the log to see if there is any info message about why the records are getting rejected?

Thanks,
Preeti

Posted: Sun May 31, 2009 9:53 pm
by shalini11
Column is Varchar. In the log following error is displayed:

Xfm,0: Field 'BodyType' from input dataset '0' is NULL. Record sent to reject dataset.

Posted: Mon Jun 01, 2009 6:38 am
by Swaruparani
hi,

can u try this one:( NullToValue(DSLink3.sal,'Unknown'))

Posted: Mon Jun 01, 2009 3:49 pm
by samsuf2002
Try making the column nullable and if it's an integer then make it varchar ....if it suits your requirement..... later do the nullhandling.

Null handling for integer will be ---> if Isnull(col1) = 0 then 'Unknown'......

Posted: Mon Jun 01, 2009 9:43 pm
by shalini11
I have tried NullToValue. All the columns are varchar. It is not working.
Earlier I was giving "Null Field Value" in input Sequential file as '' then the records with nulls were getting rejected. So I changed the "Null Field Value" to null.Now records are not getting rejected but I am getting many warnings :
Xfm,0: Null string argument.

These warnings are much more than 50.Please help in getting rid of this warning.

I am not able to understand why the derivations are working by giving "Null Field Value" as null not ''. Can you pls help.

Posted: Mon Jun 01, 2009 10:04 pm
by samsuf2002
Are those columns set as not nullable ? If yes then set them to nullable in seq file and transformer.

What is your job design ?
When you make it as nullable then edit the column and set the null field values = ''.

Posted: Tue Jun 02, 2009 2:34 am
by shalini11
The columns are nullable in seq file and transformer. In Seq file, in Formats tab, I have given the Null Field Value as '' but now I have changed it to null.