As is known to all, Java provides a split () string method for splitting strings, so it is easy to split the string into a string array with the specified symbol. However, the split () method in Java is not provided in PL/SQL, so it is necessary to do it yourself if you want to implement string segmentation in PL/SQL. Because this kind of method needs to be used in the project, so I have researched it for reference. Here is an example of a comma as a delimiter, with the following code:
1 Declare2V_strvarchar2( $) := 'abd,324,u78,23f,sd09,2345,dsaf,9079'; 3Type Str_table_type is Table of varchar2( -);4Strarr Str_table_type:=Str_table_type ("');5V_indexinteger:= 1;6 begin7 while(Length (V_STR)-LengthReplace(V_str,',',"')))> 0Loop8Strarr (V_index):=SUBSTR (V_STR,1, InStr (V_str,',',1,1)-1);9V_STR:=substr (V_str,instr (V_STR,',',1,1)+1);Ten Strarr.extend; OneV_index:=V_index+ 1; A EndLoop; -Strarr (V_index):=V_str; - forIinchStrarr.first. Strarr.last Loop the Dbms_output.put_line (Strarr (i)); - EndLoop; - End;
PL/SQL implements a small example of the split () method in Java