I am trying to create a select list in ApEx based off of values stored inside of a collection object.
Basically I am running a stored procedure that calls a java class, which sets the values of an array of varchar2.
To get the values and print them to dbms output, I can run the following PLSQL block:
DECLARE
vArray testschema.stringarray_type := testschema.stringarray_type();
BEGIN
testschema.getLOV(vArray);
FOR i IN 1..vArray.COUNT LOOP
DBMS_OUTPUT.PUT_LINE('Counter: ' || i || ' Value: "' || vArray(i) || '".');
END LOOP;
END;
Now I just need to get all of those values into a select list instead of printing them out.
How can I rewrite this PLSQL code to instead work for the LOV source of a select list?
Is there a way that I change the code to do something like this:
FOR i IN 1..vArray.COUNT LOOP
:P1_SELECT_LIST.append(vArray(i));
END LOOP;
and run that in a dynamic action or something?
Thanks
EDIT:
I made a temporary workaround where now I use a dynamic action on page load to run some PLSQL. I append each value from the object to a varchar2 variable in my plsql block, delimited by commas. I then set a hidden page item equal to the value of that variable, so it holds a value of something like:
item1,item2,item3,item4,item5
and then through a javascript dynamic action, I split the item value on the commas, and then replace the html of the select list with a custom-built html string to have all of my items listed as options.
This isn't my ideal solution, so I would still like to figure out if there is a better way. Or perhaps part of this workaround can be used in a better solution.