Search This Blog

Showing posts with label PASS PARAMETERS. Show all posts
Showing posts with label PASS PARAMETERS. Show all posts

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.


Monday, June 23, 2025

How Do I Pass parameters to other page in application

 

How Do I Pass parameters to other page in application

Introduction

In Oracle APEX, creating seamless navigation between pages is essential for building dynamic, user-friendly applications. One powerful feature that enables this is the ability to pass parameters between pages. Whether you're transferring an employee ID to a detail view or preserving filter settings across navigation, parameter passing allows for personalized and context-aware user experiences. In this guide, we’ll walk through how to pass values from one page to another using built-in APEX functionality like buttons, links, and URL syntax, ensuring your applications are both interactive and efficient.


A screenshot of a computer

Description automatically generated


A screen shot of a computer

AI-generated content may be incorrect.


A screenshot of a computer

Description automatically generated

Objective:

Pass values (parameters) from one page (source) to another page (target) in your APEX application, enabling context-aware navigation (e.g., from a report to a detail view, or from a dashboard to a filtered form).

METHOD 1: Using a Button (Redirect with Parameters)

Step-by-Step:

Step 1: Ensure Page Items Exist

  • On Page A (source), ensure the item holding the value exists (e.g., P1_DEPT_ID).
  • On Page B (target), create a matching page item (e.g., P2_DEPT_ID) to receive the value.

ep 2: Create a Button

  • Page Designer for Page A:
    1. Add a button (e.g., GO_TO_DETAILS).
    2. Set Action = “Redirect to Page in this Application”.
    3. Set Target Page = e.g., 2 (Page B).

Step 3: Set Parameters

  • Scroll to Set Items.
  • Add a row:
    • Name: P2_DEPT_ID
    • Value: &P1_DEPT_ID. (or select P1_DEPT_ID from dropdown)

This maps P1_DEPT_ID from Page A to P2_DEPT_ID on Page B.

Step 4: Use on Target Page

  • On Page B, reference :P2_DEPT_ID in SQL reports, forms, or PL/SQL code.

·         SELECT * FROM DEPARTMENTS WHERE DEPARTMENT_ID = :P2_DEPT_ID

 

METHOD 2: Using a Link in a Report (e.g., IR/IG/Classic)

Step-by-Step:

Step 1: Create Link Column

  • In an Interactive Report or Classic Report:
    • Go to Column Attributes.
    • Click Link.
    • Set Link Target:
      • Page: 2
      • Set Items:
        • Name: P2_EMP_ID
        • Value: #EMPLOYEE_ID# (substitute column name)

Step 2: Create Matching Item on Target Page

  • On Page B, ensure P2_EMP_ID exists.

Step 3: Use Parameter

  • Use :P2_EMP_ID in target page regions or logic.

METHOD 3: Manual URL with Parameters

This is useful for PL/SQL-generated links, dynamic actions, or navigation menus.

URL Format:

f?p=&APP_ID.:2:&SESSION.::NO::P2_DEPT_ID:&P1_DEPT_ID.

Breakdown:

  • &APP_ID. – current application
  • 2 – target page
  • &SESSION. – session
  • P2_DEPT_ID – receiving item
  • &P1_DEPT_ID. – source value

Use this format in dynamic PL/SQL blocks or links.

 

 Important Notes
  •  Always ensure "Maintain Session State" is enabled for the target item.
  •  Avoid passing sensitive data unless encrypted.
  •  Use Before Header processes on the target page to act on parameters early.

 

Real-Life Example

You have a report on Page 1 listing departments. You want users to click a button or link and go to Page 2 to see employees in that department.

  1. Report has DEPARTMENT_ID.
  2. Create link/button → target Page 2 → set P2_DEPT_ID = DEPARTMENT_ID.
  3. On Page 2, use:

4.  SELECT * FROM EMPLOYEES WHERE DEPARTMENT_ID = :P2_DEPT_ID



Here  is another example with Images

A screenshot of a computer

AI-generated content may be incorrect.



A screenshot of a computer

Description automatically generated

Conclusion

Passing parameters between pages in Oracle APEX unlocks a wide range of possibilities, from maintaining user context to driving targeted reports and forms. By leveraging built-in tools like button actions, URL parameters, and item value mappings, developers can create intuitive workflows without writing extensive custom code. Mastering this technique is a key step toward building robust and interactive APEX applications that respond intelligently to user actions.