DECLARE
TYPE record_AB IS RECORD
(
AA VARCHAR2 (16 BYTE),
BB VARCHAR2 (16 BYTE)
);
TYPE type_tab_AB IS TABLE OF record_AB
You cannot query a type created inside a pl/sql block. You need to create it at sql prompt and then you can query it. See exmaple below :
scott@ORA92> CREATE OR REPLACE TYPE emp_type AS OBJECT
2 (id NUMBER,
3 name VARCHAR2(20));
4 /
Type created.
scott@ORA92> CREATE OR REPLACE TYPE emp_tab AS TABLE OF emp_type;
2 /
Type created.
scott@ORA92> VARIABLE g_ref REFCURSOR
scott@ORA92> DECLARE
2 employees emp_tab := emp_tab();
3 BEGIN
4 employees.EXTEND(2);
5 employees(1) := emp_type (1, 'name1');
6 employees(2) := emp_type (2, 'name2');
7 OPEN :g_ref FOR
8 SELECT * FROM TABLE (CAST (employees AS emp_tab));
9 END;
10 /