<pre name= "code" class= "SQL" > This is a case of a select To_number (strvalue) as Value from table (' Fn_split ', ', ') using the string cut function ) Select To_char (strvalue) as Value from table (Fn_split (' aa,bb,cc ', ', '))
</pre><pre name= "code" class= "SQL" > Functions:
</pre><pre name= "code" class= "SQL" >create OR REPLACE FUNCTION root.fn_split (p_str in VARCHAR2, P_deli Miter in VARCHAR2) RETURN Ty_tbl_str_split is j INT: = 0; I INT: = 1; -The length of the source string being cut. Len INT: = 0; --separates the length of the string len1 INT: = 0; -The text information for each cell in the middle of the staging. STR VARCHAR2 (4000); --Expected return results. Str_split Ty_tbl_str_split: = Ty_tbl_str_split (); BEGIN-The length of the source string being cut. Len: = LENGTH (P_STR); --separates the length of the string. Len1: = LENGTH (P_delimiter); --traverse the source string being cut. While J < Len LOOP--queries the delimited string in the source string being cut. J: = INSTR (P_str, P_delimiter, i); IF j = 0 Then-j=0 means not found. --can be understood as a query to the last unit. --Set J: = Len, so that the external loop processing can end. J: = Len; --Gets the contents of the last cell. str: = SUBSTR (P_str, i); --Adds a row to the result. Str_split. EXTEND; --Set the result content. Str_split (Str_split. COUNT): = ty_row_str_split (strvalue = str); IF i >= Len then EXIT; END IF; ELSE--assumed to be in the source string being cut. A delimited string was found. --First. Gets the content of the cut. str: = SUBSTR (P_str, I, j-i); --then set the index. Next time you look for it again. Start at the specified index (not from 0) I: = j + len1; --Add a good result. Str_split. EXTEND; --the contents of the result set. Str_split (Str_split. COUNT): = ty_row_str_split (strvalue = str); END IF; END LOOP; RETURN Str_split; END Fn_split;
It will be converted to a function to display data rows with comma-delimited columns of data in a row