Pl/sql implementation of the split () method in Java example _java

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.