Split string return array

tags: Java  J#  .net  Blog

CREATE OR REPLACE TYPE mytable AS TABLE OF varchar2(100)  



CREATE OR REPLACE FUNCTION split
(src VARCHAR2, delimiter varchar2)
RETURN mytable IS
psrc VARCHAR2(500);
a mytable := mytable();
i NUMBER := 1; --
j NUMBER := 1;
BEGIN
psrc := RTrim(LTrim(src, delimiter), delimiter);
LOOP
i := InStr(psrc, delimiter, j);
--Dbms_Output.put_line(i);
IF i>0 THEN
a.extend;
a(a.Count) := Trim(SubStr(psrc, j, i-j));
j := i+1;
--Dbms_Output.put_line(a(a.Count-1));
END IF;
EXIT WHEN i=0;
END LOOP;
IF j < Length(psrc) THEN
a.extend;
a(a.Count) := Trim(SubStr(psrc, j, Length(psrc)+1-j));
END IF;
RETURN a;
END;


Array as a query condition for select in


SELECT * FROM student WHERE id IN (SELECT * FROM TABLE(CAST(split('001,002', ',')AS mytable)));   




SELECT * FROM student WHERE id IN
(
SELECT id FROM student WHERE id='001'
UNION
SELECT * FROM TABLE(CAST(split('001,002',',') AS mytable))
);


This article comes from the CSDN blog, please indicate the source: http://blog.csdn.net/believefym/archive/2009/01/15/3791122.aspx

Intelligent Recommendation

Split MFC string into array

C++ wants to achieve dynamic array effects like other languages ​​need to use STL container, so the return value is stored in a Vector container, Vector container can access the elements in the queue ...

Shell string split into array

1. String 2. Split 3. Output...

The split string to the dynamic array

String format "123,345,124,1234,123,4" Segmentation Analysis into 123 345 124 1234 123 4 Dynamic open space Effect...

The split method of the String class, the string is split into an array

The split method of the String class can split a string into an array of strings according to a specific separator. The parameter regex is a regular expression, and the string represented by the regex...

More Recommendation

Use split method to split string and return string list object

Python provides a very powerful string splitting method split, which can split a given string (s) according to a custom split character, generate a string list (ssl), and arrange the substrings after ...

C ++ string char [] array split Split

STRTOK provided by C ++ for string array segmentation, don't say, on the code: Output results:...

C#--string split, return index value

table of Contents mind Mapping 1. Conversion between string and array 2. Case conversion 3. String processing-the return type is of type bool 4. Find the index value 5. String regular processing-retur...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top