cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Variable length in substring

Former Member
0 Likes
353

i am trying unsuccessfully to write a udf, as suddenly the fixed length field i was using a substring on has changed to a variable length field...

i need to pass the field into a UDF and then pass out the last two characters for one field...

and the last 5 for another field.

once i have the UDF working for one, i can amend it for the other...

i am probably a million miles away from the solution... but this is where i am so far...

can someone guide me as to how i can pass the variable length into the substring parameter??


String str = var1;
int length = str.length();

output(var1.substring(length -2))

}

View Entire Topic
Shabarish_Nair
Active Contributor
0 Likes

try;

int length = input.length();
String out = input.substring(length-2,length);
return out;