SoFunction
Updated on 2025-03-08

Example of PL/SQL implementing split method in JAVA

As we all know, Java provides split() string splitting methods for String class, so it is easy to split a string into an array of strings with specified symbols. However, there is no split() method in pl/sql, so you still need to do it yourself if you want to split strings in pl/sql. Since this method is needed in the project, I have studied it myself for the convenience of future reference. Here, take a comma as a separator as an example, the code is as follows:

declare
v_str varchar2(200) := 'abd,324,u78,23f,sd09,2345,dsaf,9079'; 
type str_table_type is table of varchar2(50);
strArr str_table_type := str_table_type('');
v_index integer := 1;
begin
while (length(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);
;
v_index := v_index + 1;
end loop;
strArr(v_index) := v_str;
for i in .. loop
dbms_output.put_line(strArr(i));
end loop;
end;

The above is the full description of the example of the split() method in PL/SQL introduced to you by the editor. I hope it will be helpful to you. If you want to know more, please stay tuned me!