Skip to Content
0

How to add value in queue in udf

Dec 07, 2016 at 09:30 PM

328

avatar image
Former Member

Hello,

I am newbie in udf,

I have a requirement to add value to the existing queue.

lets say i have one field A which has 10 values and need to add 11 value in the same queue.

Regards,

Roshan

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Dec 07, 2016 at 11:40 PM
0

Hi Roshan,

When you create your UDF in PI, make sure the execution type is 'All Values of Queue'. This will add a ResultList to the signature variables. Then add another signature variable of type Argument, with the Java Type as String. Leave the names as default or keep note of them.

In your UDF use code similar to this;

String str = "";
for (int i = 0; i < var1.length; i++) {
str = var1[i];
result.addValue(str);
--result.addContextChange();
}
result.addValue("daniel");

What this is doing is looping through each value in the queue and adding it to the result list. That will store your existing queue values. If you need a context change after each, uncomment the 'result.addContextChange(); code. Otherwise leave it. Then after the loop we add the additional value. In this case i am adding a String saying daniel. You can alternatively declare your own variable inside the UDF, OR create an additional parameter to pass into the function and use that in the code.

Have fun playing and let me know if you have difficulties.

Edit:

var1 is the name of the String parameter on the UDF definition.

result is the name of the ResultList parameter. If you change either of these names replace them in the code.

Share
10 |10000 characters needed characters left characters exceeded