tags:

views:

50

answers:

1

In an Oracle package I have defined a type

type setTable is table of my_sets.pkey%type;

in the package declaration (the non-body part). The pkey column referenced is a number(38). Then in a function in the package body I have

...
with d as (select column_value from table(sets)),
...

where sets is a parameter to the function of type settable. This line fails to compile with the error 'ORA-22905: cannot access rows from a non-nested table item'. What can I do to resolve this?

+4  A: 

The select statement is SQL not PL/SQL, and the SQL engine can only work with types defined on the server like this:

create type setObj is object (<attributes>);
create type setTable is table of setObj;
Tony Andrews
Just a small addition for Pip Falconer: DB defined type can be not only `object` but `table of...` or `varray` as well.
andr
Is there any way this would work in 11g but not 10g?
Pip Falconer
Not sure what you mean - "create type" has worked since 8i.
Tony Andrews
I mean would my original version work in 11g? I'm sure yours will work everywhere. I have two systems and my one *seems* to be compiling on one (which is 11g).
Pip Falconer
Oh right, no PL/SQL collections can't be used in a SELECT statement even in 11G - they just don't "exist" at the SQL level.
Tony Andrews