on 05-22-2009 7:25 AM
Hi,
I am writing a udf to assign a specific value when the incoming value is in a specific range.
The udf is
if ((i>=55201) && (i<=59999))
{
return ("X001")
}
if ((i>=65000) && (i<=67999))
{
return ("X002")
}
if ((i>=70000) && (i<=74999))
{
return ("X003")
}
when testing the mapping it is giving the following error:
operator >=cannot be applied to java.lang.String,int.
operator <=cannot be applied to java.lang.String,int.
If the value is between 55201 and 59999, i need to assign new value.
So that I have used >= and <= operators, but it is giving operator error.
Is there anyway to execute this condition.
Experts pls advise.
Thanks in advance..
Bala
what is variable i?
If it the input value/argument that is been passed to UDF, then you need to convert it before comparison
UDF by deault takes input as string.
int int_i = Integer.parseInt(i); // i is a parameter to UDF
now you can use code for comparison
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
The else part is missing in your UDF.
Try as below
public String check(String a,Container container)
{
int i = Integer.parseInt(a);
if ((i>=55201) && (i<=59999))
{
return ("X001");
}
else if ((i>=65000) && (i<=67999))
{
return ("X002");
}
else if ((i>=70000) && (i<=74999))
{
return ("X003");
}
else
{
return "Invalid";
}
}
Hi,
Within UDF all the Inputs are only of type String. First parse your string input to numeric value and continue coding the UDF.
Your requirement can done in Graphical Mapping itself rather that going with the UDF.
Thanks,
SaNv...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>Can you pls explain me, how can we do this in graphical mapping?
by using the standard functions of the "Boolean" function category. (e.g if, ifWithoutElse, ) and the standard functions from "Text" function category (e.g compare, equalsS etc)
but this would kind of text based comparisions.
although you can achieve using graphical mapping, i would recommend a small java udf, where you can have greater control.
thanks,
ganesh(g22sep)
What is the data type of i?
If it is a string value convert to int and then apply the conditons.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.