Thursday, November 7, 2013

PL SQL: Convert array into SQL table

Use:
SELECT COLUMN_VALUE FROM TABLE(my_array)
Beware to use only SQL array types or you will get the following error a run time (at least with Oracle 11.2.0.1):
ORA-21700: object does not exist or is marked for delete
E.g.
CREATE OR REPLACE TYPE MBQT_DB.ID_ARRAY_TYPE IS TABLE OF VARCHAR2(20);
/

GRANT EXECUTE ON MBQT_DB.ID_ARRAY_TYPE TO PUBLIC;