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

Source: Internet
Author: User

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

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.