Search This Blog

Tuesday, June 24, 2025

How to Pass Multiple Variables to a Second Page in Oracle APEX

 Introduction

In Oracle APEX, building responsive and interactive applications often requires transferring more than just one value between pages. Whether you're passing customer ID, region, and order status from a dashboard to a filtered report, or multiple form inputs to a processing page, Oracle APEX makes it simple to pass multiple variables during navigation. This blog post explores the various techniques available for passing multiple values—from using buttons and dynamic actions to URL parameters—ensuring your users enjoy a seamless and data-rich experience across pages.

Purpose

Passing multiple variables (parameters) from one page to another is essential in Oracle APEX when you want to transfer contextual data such as user selections, record IDs, filters, or form values between screens. Oracle APEX supports this natively using buttons, links, dynamic actions, and manual URLs.

Step-by-Step Guide: Pass Multiple Variables Between Pages

 Step 1: Prepare Page Items

On Source Page (e.g., Page 1):

Make sure you have APEX page items that hold the values you want to pass, such as:

  • P1_EMP_ID

  • P1_DEPT_ID

  • P1_STATUS

On Target Page (e.g., Page 2):

Create matching items to receive those values:

  • P2_EMP_ID

  • P2_DEPT_ID

  • P2_STATUS

Ensure that session state is enabled for all these items.

 Step 2: Pass Parameters via Button

1. In Page Designer, go to Page 1.

2. Add a Button (or use an existing one).

  • Set its Action to: Redirect to Page in this Application

  • Set Target Page to: 2 (or your target page number)

3. Scroll down to the Set Items section.

  • Click Set Items or + Add Parameter.

  • Add rows for each variable:

Name Value
P2_EMP_ID &P1_EMP_ID.
P2_DEPT_ID &P1_DEPT_ID.
P2_STATUS &P1_STATUS.

This tells APEX to send the current values from Page 1 to Page 2.

 Step 3: Use Parameters on Target Page

On Page 2:

  • Use :P2_EMP_ID, :P2_DEPT_ID, and :P2_STATUS in SQL regions, PL/SQL logic, or dynamic actions.

Example SQL Query:

SELECT * FROM EMPLOYEES 
WHERE EMPLOYEE_ID = :P2_EMP_ID
  AND DEPARTMENT_ID = :P2_DEPT_ID
  AND STATUS = :P2_STATUS

 Alternative: Pass Parameters Using Report Links

This method is used inside Interactive Reports, Classic Reports, or Grids.

1. Open the report region on Page 1.

2. Go to the column you want to make clickable (e.g., EMPLOYEE_NAME).

3. In Column Attributes, go to the Link section:

  • Link Target Page: 2

  • Set Items:

    • P2_EMP_ID#EMP_ID#

    • P2_DEPT_ID#DEPT_ID#

    • P2_STATUS#STATUS#

APEX will replace #COLUMN_NAME# with the actual row values when rendering the link.

Manual URL: Constructing f?p URLs for Custom Navigation

Useful for dynamic PL/SQL content, buttons, or navigation menus.

Example:

f?p=&APP_ID.:2:&SESSION.::NO::P2_EMP_ID,P2_DEPT_ID,P2_STATUS:&P1_EMP_ID.,&P1_DEPT_ID.,&P1_STATUS.

Explanation:

  • &APP_ID.: Current App ID

  • 2: Target page number

  • &SESSION.: Session ID

  • NO: Request (optional)

  • P2_EMP_ID,P2_DEPT_ID,P2_STATUS: Items on the target page

  • &P1_EMP_ID.,&P1_DEPT_ID.,&P1_STATUS.: Current page item values

Use this URL in:

  • PL/SQL HTP.P output

  • Dynamic action Redirect to URL

  • Navigation menu entries

 Tips & Best Practices

  •  Use session state correctly — ensure items on both pages are session-state aware.

  •  Use Before Header processes on the target page to capture and act on parameters early.

  •  Avoid passing sensitive data through URLs unless securely encrypted.

  •  Consider resetting the session state of the target page if needed.

 Summary

Oracle APEX provides several robust methods to pass multiple variables to another page:

  • Buttons with parameter mappings

  • Report links with column substitutions

  • Manual f?p URLs for dynamic scenarios

  • Dynamic actions for custom navigation logic

This enables highly contextual, user-friendly, and functional applications with little to no code.

Example:

Lets assume that you have two pages

  • Page 3 has two fields: FirstName and Last Name

  • Page 4 has two fields: FirstName and Last Name

You want to pass the values from page 3 and display them in page 4

Set the two fields in Page 3 and a button to send the data.

A screenshot of a computer

Description automatically generated

Set the two fields in page 4 

A screenshot of a computer

Description automatically generated

Go back to Page 3, select the button, and set the behavior:

  • Action: Redirect to Page in this Application

  • Target: Page 4

In the Target builder

  • Make sure that the target page is 4

  • Set items Name and Value

*NOTE: The “Name” field is the name of the field in Page 4 that you want to display the data from the Value. The “Value” is the field in Page 3 with the data that you want to display in Page 4.

A screenshot of a computer

Description automatically generated


Conclusion

Passing multiple variables between pages in Oracle APEX is a foundational skill for any developer looking to create dynamic, context-driven applications. By leveraging built-in features like button redirects, report links, and URL construction, you can transfer data efficiently and accurately. Whether you're working with forms, reports, or custom processes, understanding how to map and retrieve multiple parameters will greatly enhance the flexibility and functionality of your applications.


No comments:

Post a Comment

How Do I Make a Faceted Search Map Page in Oracle APEX

Combining faceted search with a map region in Oracle APEX enables users to filter data visually and spatially at the same time. This design ...