A small example of how PL/SQL implements the split () method in Java
As we all know, Java provides the split () String segmentation method for the String class, so it is easy to split the String into a String array using the specified symbol. However, pl/SQL does not provide the split () method in java. Therefore, you need to implement string segmentation in pl/SQL. This method is needed in the project, so I have studied it for reference later. The following code uses commas as the separator:
Declare
V_str varchar2 (200): = 'Abd, 324, u78, 23f, sd09, 2345, dsaf, 100 ';
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 );
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;
Basic Design of PL/SQL programs for Oracle databases
PL/SQL Developer Practical Skills
Use PL/Scope to analyze PL/SQL code
Use the date type in PL/SQL
How to compile and run PL/SQL code snippets from a Case Study