HOW DO I USE A STATIC LOV IN A DROPDOWN IN ORACLE APEX
Introduction
Dropdown lists are a common feature in Oracle APEX applications, allowing users to select a value from a list of predefined choices. One of the most efficient ways to build a dropdown list is by using a Static List of Values (Static LOV). Static LOVs are perfect when the options are limited, rarely change, and do not need to be stored in a database table. By using a Static LOV, developers can provide consistent choices to users while keeping the application lightweight and easy to maintain.
Detailed Explanation
In Oracle APEX, a dropdown list is often created using an item type called Select List. To populate this dropdown, you can either create a Static LOV directly on the item or define it once in Shared Components and reuse it across multiple items. A Static LOV is a collection of label-value pairs where the label (display value) is what the user sees and the return value is what the application processes or stores in the database.
When configuring the dropdown, you choose the Static LOV as the source of values. This ensures that users are restricted to valid options and prevents errors from invalid or inconsistent data entry. Static LOVs are best suited for scenarios like statuses, categories, or priorities where the values are controlled and stable.
Steps to Use a Static LOV in a Dropdown
-
Open your application in Application Builder.
-
Go to Shared Components and select Lists of Values.
-
Create a new LOV and choose From Scratch.
-
Set the type as Static and enter your Display Value and Return Value pairs.
Example:
Display Value: Pending | Return Value: P
Display Value: Approved | Return Value: A
Display Value: Rejected | Return Value: R -
Save the LOV with a meaningful name, such as APPROVAL_STATUS_LOV.
-
Now open the page that contains your form or item.
-
Add or edit an item of type Select List.
-
Under the List of Values section, choose Named LOV and select APPROVAL_STATUS_LOV.
-
Save and run the page. Your dropdown will now display the static values, and when the user makes a selection, the corresponding return value will be stored or processed.
Extensive Example
Imagine you are building a task management form where each task has a priority. Create a Static LOV named TASK_PRIORITY_LOV with these values:
Display Value: Low | Return Value: 1
Display Value: Medium | Return Value: 2
Display Value: High | Return Value: 3
In the form, create a Select List item called Task Priority. Associate it with TASK_PRIORITY_LOV. When the user selects “High” from the dropdown, the value stored in the database will be 3. This makes reporting and filtering easier because you work with consistent return codes, while users see friendly labels.
Best Practices
-
Always create LOVs in Shared Components when they are reused across multiple pages. This ensures consistency and simplifies maintenance.
-
Use descriptive display values for clarity, but keep return values short and standardized for efficient storage.
-
Consider using codes for return values (like 1, 2, 3 or P, A, R) and descriptive labels for display values.
-
If the values are likely to change over time, consider switching to a Dynamic LOV sourced from a database table instead of a Static LOV.
-
Provide a default or null display value like “Select an option” to improve usability.
Example:
Add a “select one” dropdown box and attach a “Shared components” list of values
Here is how it looks on the page
For more information, refer to the official Oracle APEX documentation on Lists of Values:
https://docs.oracle.com/en/database/oracle/apex/24.2/htmdb/using-lists-of-values.html
Using a Static LOV in a dropdown is one of the simplest and most effective ways to control user input in Oracle APEX. It guarantees that users only select from valid options, ensures consistency across the application, and reduces the need for additional database tables when values are stable. By following best practices and leveraging Shared Components, you can create dropdowns that are both user-friendly and maintainable. Static LOVs provide an excellent balance between simplicity and reliability, making them a key tool in every APEX developer’s toolkit.