cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for comparing first variable with array of second variable and pass third variable if equal

Former Member
0 Kudos


Hi Experts,

My requirement is : I will get three variables from source. All contexts are different.

I need UDF for first variable(Var1) should compare with array of second variable(Var2 array of values) and pass the third variable if first variable is equal to any of the variable in Var2 array.

Appreciate your help on this.

Example:

Var1:

4

5

4

6

5

4

4

Var2:

1

2

3

4

5

Var3:

1001

1002

1003

1004

1005

1006

1007

Result:

1001

1002

1003

1005

1006

1007

Note: 1004 is not there in result because in var1 6 is not matched with array of var2 values.

Thnaks & regards,

A.Neelima.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Neelima

Use the below code.

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

  for(int j=0;j<var2.length;j++){

  if(var2[j] == var1[i])

  resultset.add(var3[i]);

  }

  }

if var1, var2 are string then replace the if condition with the following

if(var2[j].equals(var1[i]))

Note: length of Var1 and Var3 should be always equal.

Regards

Osman

Answers (1)

Answers (1)

Former Member
0 Kudos