I have a procedure that accepts an input similar to parent_arr shown below as input from the application layer via ODP.Net. In the first step of the procedure, I store data from the array in a global temporary table so I can proceed with several following steps using set logic rather than pl/sql loops. As long as the array has only a single member of parent_typ, everything is fine. However, when there is more than one member, I get ORA-01427, single row query returns more than one row. The query below returns two collections. I need to un-nest both collections in a single sql statement that will display child.name and child.value. How can that be done?
Sample objects
create type child_typ is object( name varchar2(100), value number );
create type child_arr is table of dropme_child_typ;
create type parent_typ is object( pname varchar2(100), child dropme_child_arr );
create type parent_arr is table of dropme_parent_typ;
The query below will throw ORA-01427
select * from table(
select child
from table( parent_arr(
parent_typ( 'TEST1',
child_arr(
child_typ( 'C1', 1 ),
child_typ( 'C2', 2 ) ) ),
parent_typ( 'TEST2',
child_arr(
child_typ( 'C3', 3 ),
child_typ( 'C4', 4 ) ) ) ) ) );
This query works, but returns a column of object child_arr
select child
from table( parent_arr(
parent_typ( 'TEST1',
child_arr(
child_typ( 'C1', 1 ),
child_typ( 'C2', 2 ) ) ),
parent_typ( 'TEST2',
child_arr(
child_typ( 'C3', 3 ),
child_typ( 'C4', 4 ) ) ) ) );
This query fails because I can't access values in "child"
select child.name, child.value from
table( parent_arr(
parent_typ( 'TEST1',
child_arr(
child_typ( 'C1', 1 ),
child_typ( 'C2', 2 ) ) ),
parent_typ( 'TEST2',
child_arr(
child_typ( 'C3', 3 ),
child_typ( 'C4', 4 ) ) ) ) );
Please tell me there is a way to do this without using a pl/sql loop (that is the only way I've been able to succeed so far). Speed is of the utmost importance. I tried using a forall statement to loop through memebers of the parent_arr, but it throws a bulk in-bind error.