问题
I have a collection of array's, currently the code
select apex_collections.c001 from apex_collections where collection_name = 'LOAD_CONTENT'
Shows the below on screen.
C001
570
571
I have another table called errorTable that has a column Table1ID that matches with the values contained within the C001 array. I need to display all the records within the errorTable to the user where there is a match. In this example I want to show all records in errorTable where Table1ID match '570' or '571'.
I'm thinking I need to do a loop through the apex_collections C001 array and then do something like select * from errorTable where apex_collections.c001(i) = errorTable.Table1ID
I'm trying to get help on how to write this loop as I'm struggling a bit with that.
回答1:
You could do something like the following:
select apex_collections.c001 from apex_collections apex inner join errorTable errors on apex.c001 = errors.Table1ID where apex.collection_name = 'LOAD_CONTENT'
inner join
will give you only records from errorTable that match the values contained in the C001 column
Please take a look at the specification of Microsoft for more info regarding INNER JOINs
回答2:
Create a new region. Type: "PL/SQL Dynamic Content".
In the part for "PL/SQL Code". Put in something like:
begin
htp.prn ('<b>Rows with errors:</b><br><br>');
for i in (select errortable.*
from errortable, apex_collections
where apex_collections.c001 (i) = errortable.table1id
and apex_collections.collection_name = 'LOAD_CONTENT') loop
htp.prn (i.column1 || '<br>');
end loop;
end;
This join makes sure that only records from apex_collections are shown that have a matching entry in errortable
You can also simply create a report region (classic/interactive) and use the SQL as source:
select errortable.*
from errortable, apex_collections
where apex_collections.c001 (i) = errortable.table1id
and apex_collections.collection_name = 'LOAD_CONTENT'
来源:https://stackoverflow.com/questions/32930072/apex-collections-how-do-i-loop-through-an-apex-collection-of-arrays