cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced UDF using context

Former Member
0 Kudos

Hi

I have wrote a below Advanced UDF (using context). But I want to return string array "temp" through "result". My below code throug error as last "result" statement is wrong. If anybody knows how to define this statement could you plz help me out ?? Any help in this regard is highly appreciated.

******************************************************

String[ ] temp = new String[1000000000];

for (int i = 0; i < a.length; i++) {

if ((Integer.parseInt(a<i>) == 11) || (Integer.parseInt(a<i>) == 12) || (Integer.parseInt(b<i>) == 4)) {

temp<i> = "1";

temp<i> = "0";

}

}

// String temp1 = Arrays.toString(temp).

result = (temp [ ]);

****************************************************

Thanks in advance

kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kumar

I assume you have defined your UDF with a Context cache. As such all input parameters will be arrays. So even the single value of is passed in this way. And your output is the result list array

I think you need to use the statement for build up your result array

result.addValue(temp.toString());

Please try that and see if that helps.

Answers (2)

Answers (2)

Former Member
0 Kudos

If you need to output the value of 'temp',then you can try this code : -

String temp = null;

for (int i = 0; i < a.length; i++) {

if ((Integer.parseInt(a) == 11) || (Integer.parseInt(a) == 12) || (Integer.parseInt(b) == 4))

{

temp = "1";

result.addValue(temp);

}

else

{

temp = "0";

result.addValue(temp);

}

}

Regards

Priyanka

Former Member
0 Kudos

>>temp = "1";

temp = "0";

This doesn't looks good to me,temp is an array of strings,isn't it?

won't you be giving index as well like temp[0] and temp[1]?

and secondly what type of variable is Result?

if its of type Resultlist then won't you be using result.append instead of directly assiging an array to it?

Thanx

Aamir

Message was edited by:

Aamir Suhail