Search This Blog

Showing posts with label Use a Static LOV in a dropdown page. Show all posts
Showing posts with label Use a Static LOV in a dropdown page. Show all posts

Thursday, August 21, 2025

HOW DO I USE A STATIC LOV IN A DROPDOWN IN ORACLE APEX

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

  1. Open your application in Application Builder.

  2. Go to Shared Components and select Lists of Values.

  3. Create a new LOV and choose From Scratch.

  4. 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

  5. Save the LOV with a meaningful name, such as APPROVAL_STATUS_LOV.

  6. Now open the page that contains your form or item.

  7. Add or edit an item of type Select List.

  8. Under the List of Values section, choose Named LOV and select APPROVAL_STATUS_LOV.

  9. 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

  1. Always create LOVs in Shared Components when they are reused across multiple pages. This ensures consistency and simplifies maintenance.

  2. Use descriptive display values for clarity, but keep return values short and standardized for efficient storage.

  3. Consider using codes for return values (like 1, 2, 3 or P, A, R) and descriptive labels for display values.

  4. 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.

  5. 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

A screen shot of a graph

Description automatically generated

Here is how it looks on the page

A screenshot of a computer

Description automatically generated

Oracle APEX Documentation

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.


Monday, June 30, 2025

How Do I Use a Static LOV in a dropdown page

 Introduction

Using a static List of Values (LOV) in a dropdown page in Oracle APEX allows you to present a fixed set of options to users in a select list. This is especially useful for fields like categories, status indicators, or levels where the choices don’t change frequently. Static LOVs improve data consistency and simplify form design by eliminating the need for dynamic SQL queries. In this blog, you’ll learn how to create and apply a static LOV to a dropdown list in a form page.

To use a static List of Values (LOV) in a dropdown page in Oracle APEX, you define a fixed set of label-value pairs that populate a select list. This type of LOV is ideal for situations where the options do not need to be pulled from a database, such as status values like "Open", "In Progress", or "Closed". Here's how to set it up step by step.

Step 1: Open Your Application and Go to the Target Page
Open Oracle APEX, select your application, and navigate to the page where you want to place the dropdown. You can use an existing form page or create a new one.

Step 2: Add a Select List Item
In Page Designer:

  • Under the appropriate region, click + to add a new item.

  • Choose Select List as the item type.

  • Set the item name, such as P1_STATUS.

  • Set the label, such as Status.

Step 3: Define the Static LOV
With the P1_STATUS item selected:

  • Scroll to the List of Values section.

  • For Type, choose Static Values.

  • In the Static Values box, enter values in this format:

Open;OPEN  
In Progress;IN_PROGRESS  
Closed;CLOSED

Each line represents one option, where the text before the semicolon is what users see (label), and the text after is what gets submitted (value).

Step 4: Configure Optional Settings
You can fine-tune how the dropdown behaves:

  • Display Null Value: Turn on if you want to show a blank first option like - Select -.

  • Null Display Value: Set the label for the blank option, e.g., - Select Status -.

  • Session State: Ensure session state is enabled so the selected value is stored and available to processes or conditions.

Step 5: Save and Run the Page
Click Save, then Run the page. You should now see a dropdown that shows the static options defined earlier.

Example Use Case
A common use of a static LOV dropdown is for selecting a risk level:

Low;LOW  
Medium;MEDIUM  
High;HIGH

This lets users pick a level easily without pulling values from a table.

Benefits of Using Static LOVs

  • Fast to implement

  • No dependency on database queries

  • Easy to maintain for small sets of fixed options

  • Great for select lists, radio groups, or checkbox groups

Static LOVs are ideal for dropdowns with consistent values across the application, giving you a simple, clean method to control user input.

Add a “select one” dropdown box and attach a “Shared components” list of values

A screen shot of a graph

Description automatically generated

Here is how it looks on the page

A screenshot of a computer

Description automatically generated

Conclusion
Implementing a static LOV in a dropdown list is a quick and effective way to guide users toward consistent input. It ensures valid selections, streamlines form usability, and reduces development complexity when dealing with predefined values. Oracle APEX makes it easy to create and assign static LOVs, allowing you to build cleaner and more user-friendly applications.

HOW DO I USE A STATIC LOV IN A DROPDOWN IN ORACLE APEX

HOW DO I USE A STATIC LOV IN A DROPDOWN IN ORACLE APEX Introduction Dropdown lists are a common feature in Oracle APEX applications, allo...