on 02-07-2007 9:23 PM
why do following UDF giving error. It is expecting return statement from else part. I donot want else part of If stmt Iam writing.
<i>public String GroupTest(String a,Container container){
if (a.equals("ExportOne")) return "One";
if (a.equals("ExportTwo")) return "Two";
if (a.equals("ExportThree")) return "Three";</i>
What is problem with above UDF?. I want If statements without else part. Can someone please help me.
Im writing this as part of message splits. So please do not suggest to use fixvalues mapping or something else. I am just looking for multiple if statements without else part.
Thanks
RK
Hi Ram,
Any java function should return some value in ur case as all the return statements are with in IF statement so code will not compile.
So put a dummy return statement at the end.
return " ";
Regards,
Kavitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
the method has to return something in every case so here it is claiming a missing
...
else
return "something";
Why don't you go for something like:
return a.replaceFirst("Export","");
Regards,
Sergio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
can you try this:
if (a.equals("ExportOne"))
{
return "One";
}
else if (a.equals("ExportTwo"))
{
return "Two";
}
else
{
return "nothing";
}
Regards,
michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ram,
the problem you are facing is may be because
the input to the udf isnt one of the ExportOne,ExportTwo or ExportThree
please make it sure that you are sending them
otherwise it wo'nt ask for 'else'
and see to it that udf must return something.
Ranjit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.