-- Oracle 10G or 11G
-- built-in Apex function
apex_util.string_to_table()
DECLARE
V_String VARCHAR2(100) := 'A,B,C,D';
V_Array apex_application_global.vc_arr2;
BEGIN
V_Array :=
apex_util.string_to_table(V_String, ',');
FOR i IN 1 .. V_Array.COUNT LOOP
DBMS_OUTPUT.Put_Line(V_Array(i));
-- insert table syntax
END LOOP;
END;
-- Using REGEXP_SUBSTR()
SELECT REGEXP_SUBSTR('A,B,C,D', '[^,]+', 1, LEVEL) AS data
FROM dual
CONNECT BY REGEXP_SUBSTR('A,B,C,D', '[^,]+', 1, LEVEL) IS NOT NULL;
-- Using xmltable()
-- Split number to table
-- Note: It's only work
for number
SELECT TO_NUMBER(COLUMN_VALUE) as data from xmltable('1,2,3,4,5');
-- VARRAY(10) :- Size of
array
-- VARCHAR2(20) :- Size
of String Value
DECLARE
TYPE V_Array IS VARRAY(10) OF VARCHAR2(10);
V_String
V_Array;
BEGIN
V_String :=
V_Array('A', 11, 22, 'B');
FOR i IN 1 .. V_String.Count LOOP
dbms_output.put_line(V_String(i));
-- insert table syntax
END LOOP;
END;
No comments:
Post a Comment