Hi I have a table column in Oracle 10 which contain a string array like that:
TERMS_TABLE
DOC_ID | TERMS_ARRAY
120 | apple,orange,banana,.....,termN
There are N terms. I want to separate commas from the TERMS_ARRAY and insert them another table
COMMA_SEP_TABLE
DOC_ID |TERM
120 | apple
120 | orange
120 | banana
.....
I try these code but it does not do anything :
CREATE OR REPLACE SEPERATE_COMMA IS
l_tab DBMS_UTILITY.LNAME_ARRAY ;
l_tablen number;
CURSOR CUR1 IS SELECT * FROM TERMS_TABLE ;
BEGIN
EXECUTE IMMEDIATE ('TRUNCATE TABLE COMMA_SEP_TABLE);
FOR R IN CUR1
LOOP
DBMS_UTILITY.comma_to_table (R.TERMS_ARRAY, l_tablen, l_tab);
FOR i IN 1 .. l_tablen
LOOP
INSERT INTO COMMA_SEP_TABLE
VALUES (R.DOC_ID, l_tab (i));
COMMIT;
END LOOP;
END LOOP;
END;
How can separate commas ?