Page 1 of 2
Null Handling
Posted: Fri Jul 24, 2009 12:13 pm
by Prakash3366
Hi All
i have salary column , but few fields are null. If salary is null then i want 999 in the target otherwise i want the salary itself.
Ex:
Input:
ID|NAME|SALARY
101,RAY,10000
102,CHIRS,
103,RAM,20000
104,JESSY,
Output i want as :
ID|NAME|SALARY
101,RAY,10000
102,CHIRS,999
103,RAM,20000
104,JESSY,999
Thanks in advance.
Posted: Fri Jul 24, 2009 12:45 pm
by Sainath.Srinivasan
search for isNull or NullToZero
Posted: Fri Jul 24, 2009 2:01 pm
by ddevdutt
NullToValue should get you your output
Posted: Fri Jul 24, 2009 2:45 pm
by chulett
You'd have to create a NullToValue transform as it does not ship with the Server product, but it is quite easy to write. Or do the equivalent IF-THEN-ELSE check directly in the derivation using IsNull() as noted.
Null Handling
Posted: Sat Jul 25, 2009 11:37 am
by Prakash3366
Thanks for everybody. I know NullToValue in parallel but in server if i use IF THEN ELSE , I am not getting the desired value.. i am getting only null values in place of null values in the target. so please reply..
Thanks
Posted: Sat Jul 25, 2009 1:37 pm
by chulett
Post your syntax.
Posted: Mon Jul 27, 2009 1:00 pm
by Prakash3366
chulett,
Thanks for your reply. i am putting the following syntax
If column=isNull then 999 else '0'
Please correct if i am wrong
Thanks
Prakash
Posted: Mon Jul 27, 2009 1:37 pm
by chulett
IsNull() is a function and you said you wanted to retain the value if not null so:
If IsNull(column) then 999 else column
Posted: Tue Jul 28, 2009 10:48 am
by Prakash3366
Chulett,
Thanks for your quick reply and i have mentioned as you are said , but still i am not getting solution for this.
If IsNull(a.SALARY) then 999 else a.SALARY.
Here is the a is the source link.
if i put this condition , i am not getting 999 in the place of null, i am getting only null in the null place.
So please reply for the same..
Thanks
Posted: Tue Jul 28, 2009 10:50 am
by chulett
Then your Salary field is not null. You may need to add a check for that field being "empty" as well. What data type is it?
Posted: Wed Jul 29, 2009 12:34 pm
by Prakash3366
chulett,
I want to explain the job.
my source has three columns. ID, Name and salary.
the datatype of these columns is integer, varchar and integer respectively.
i checked option, Nullable is Yes for salary column. But still i am not getting desired result.
can you help me about this.
Thanks
Posted: Wed Jul 29, 2009 2:59 pm
by ddevdutt
Like Craig mentioned, you probably have values that are not null in the Salary field. Hence apart from checking for nulls, also check to see if those fields are empty.
Posted: Wed Jul 29, 2009 11:57 pm
by Prakash3366
Hi
in salary column, i have 10 rows . In that two ,three fields are empty values. But still i am not getting the correct result. So now you can help me about this
Thanks
Posted: Thu Jul 30, 2009 12:11 am
by chulett
What is your source for this column - flat file? Database table? Something else entirely? Assuming the first but looking for confirmation.
Posted: Thu Jul 30, 2009 5:09 am
by Prakash3366
My Source is flat file
Thanks