Oracle APEX - How to select a display value in a Popup LOV programmatically

3.2k Views Asked by At

Is there a way to set a selected value in a popup LOV using PL/SQL?

I use

:P2_MYLOV := myval

Which does set LOV's return value to myval but does not display a corresponding display value as selected. How can I select LOV's value programmatically and set a corresponding display value? Is it possible?

It did work for me at some point when my LOV was based on a SQL query and only shown one value

SELECT val_id
FROM Table1
WHERE field1 = 'test'
AND parent_id = :P2_ITEM1;

but once I set it to a shared component List of Values with multiple columns, it stopped working

1

There are 1 best solutions below

0
On

It's not quite clear what you're asking. My biggest question is when are you trying to change the value. I'm guessing you have an Apex item that is a Popup LOV on a page somewhere and you want a value selected when the page loads?

You've got the item Source, which is a calculation that controls what the populated value is when the page loads. This can be done by a PL/SQL expression, a SQL query, or something else. That can be calculated anew each time, "Always, replacing any value in session state" or when there is no value in session state "Only when current value in session state is null".

The other option is the Default, which is the value used if the value is still null after the Source has been calculated. That can also be an expression or a query.

If you are trying to change the value of an item in the browser, say in response to some user action, then you want a Dynamic Action, which would not use PL/SQL. The only time that would come into play is if the new value could only be calculated in the database, and Apex needed to do a round trip to the database, but that's uncommon.

[I just tried the Dynamic Action on a Popup LOV on apex.oracle.com and it did not work. I'm not sure why. It works ok with a regular select list, though.]