As we all know, Java provides a split () string split method for the string class, so it's easy to split the string into a string array with the specified symbol. However, the split () method in Java is not provided in the pl/sql, so it is necessary to implement the string segmentation in the Pl/sql. Because in the project need to use this kind of method, so oneself research a bit, convenient later reference. As an example of a comma as a delimiter, the code is as follows:
DECLARE
v_str varchar2: = ' abd,324,u78,23f,sd09,2345,dsaf,9079 ';
Type Str_table_type is Table of VARCHAR2 (m);
Strarr Str_table_type: = Str_table_type (");
V_index integer: = 1;
Begin while
(V_STR)-length (replace (v_str, ', ', ')) > 0 Loop
strarr (v_index): = substr (v_str,1, InStr (V_str, ', ', 1,1)-1);
V_STR: = substr (V_str,instr (V_str, ', ', 1,1) +1);
Strarr.extend;
V_index: = V_index + 1;
End Loop;
Strarr (v_index): = V_str;
For I in Strarr.first. Strarr.last Loop
dbms_output.put_line (Strarr (i));
End Loop;
End
The above is a small set to introduce the PL/SQL implementation of Java in the split () method of the full description of the example, I hope to help you, if you want to know more content, please pay attention to cloud habitat community!