Skip to Content
avatar image
Former Member

UDF to collect the values in single context


Dear All,

I am planning to send collecting values from my row each columns and send to target structure with in single context separated by characters.

Could you suggest me how could I write UDF

For ex:

Thanks in Advance.

Sateesh

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Mar 24, 2015 at 05:29 AM

    Sateesh

    You can try the logic below with a UDF of Execution type "All Values of Queue", with a single input a

      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < a.length; i++) {
       sb.append("||").append(a[i]);
      }
      sb.append("||");
      result.addValue(sb.toString());
    

    Test results

    You can adjust the logic accordingly if you need further tweaking.

    Rgds

    Eng Swee


    udf.png (12.8 kB)
    result.png (18.6 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Sateesh

      You need to also adjust the mapping as well for the target parent segment storedProcedureName.

      Create another UDF of execution all values of queue with the following logic

        for (int i = 0; i < a.length; i++) {
         if((i % 5) == 0) {
          result.addValue("");
         }
        }
      

      Your mapping logic should look like that - I've named the second UDF parent but you can choose whatever name you like.

      After executing the entire mapping, it would look like that

      If you want to, it is also possible to combine the two UDFs into a single one with two outputs, but I leave that to you if you desire so.

      Rgds

      Eng Swee

      queue.png (35.1 kB)
      res2.png (7.6 kB)