Du skal bruge et SQL-objekt for at kalde TABLE
operator fra en SELECT
. Her er et lille eksempel (9iR2):
SQL> CREATE TYPE table_number is TABLE OF NUMBER;
2 /
Type created.
SQL> SELECT * FROM TABLE(table_number(1,2,3));
COLUMN_VALUE
------------
1
2
3
Du kan bruge en funktion her i stedet (bemærk at min TYPE stadig er defineret uden for pakken):
SQL> CREATE OR REPLACE PACKAGE pkg AS
2 FUNCTION f RETURN table_number;
3 END;
4 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY pkg AS
2 FUNCTION f RETURN table_number IS
3 BEGIN
4 RETURN table_number(4,5,6);
5 END;
6 END;
7 /
Package body created.
SQL> SELECT * FROM table(pkg.f);
COLUMN_VALUE
------------
4
5
6