I'm currently trying to create a dynamic action inside of Oracle APEX using a PL/SQL script that counts the amount of Yes and N/A responses in a table and return a percentage of the progress towards every cell being a Yes or N/A. Since the table is pretty large I was thinking that putting all of the column headers into an array and running the select statement in a for loop would be the most efficient way to do this. Here is what I have so far:
DECLARE
type array IS VARRAY(20) OF VARCHAR2(1000);
columns_array array := array('...','...',...);
arr_Size number(4, 2) := 20;
Counter number(5, 2);
Progress number(5, 2);
BEGIN
FOR i in 1..arr_Size
LOOP
select COUNT(columns_array(i))
into Counter
from Table
where array(i) = 'Yes' OR array(i) = 'N/A';
Progress := Progress + Counter;
END LOOP;
END;
The program compiles without any errors but the code outputs zero for progress after running when it shouldn't. I think the problem is that I used an array inside of the select statement, but I don't know any other way to accomplish what I'm trying to do.