PL/SQL implements a small example of the split () method in Java

Source: Internet
Author: User

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

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.