on 12-16-2014 2:21 PM
Hi i am getting following error in udf - string index out of range 9 from substring function from following code -
str = str1.substring(0, 9); kindly give solution for it.
Thanks
Mrityunjoy
Hi,
You can achieve this using a UDF or with Std Graphical mapping (if there are no further complex checks involved)
1. An alternative approach would be as follows. This UDF will not give you errors when length is Less than 9, nor it will fail if the Source node is absent/ empty
str = str1.substring(0, Math.min(9, str1.length()));
2. You can achieve this using std Graphical mapping as well as follows:
Regards,
Azhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need to change your udf like below
if(str1.length() > 10) then use str1.substring(0,9) else str1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mrityunjoy,
This error will only result. if the length of the input string (str1) string is less than 10 characters.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is your str1 greater than or equal to 10 characters? Please check all the values in the context.
If not you will get this error.
Thanks,
Sudhansu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.