In Oracle APEX, Classic Reports provide a flexible way to present data using SQL queries. One common requirement is to include a manual link in the report—such as a "View", "Edit", or "Details" link—so that users can navigate to another page, pass values, or trigger actions. While Oracle APEX provides built-in options for adding links through column attributes, manually adding a link gives you greater control over the output and behavior. This blog post explains how to manually add a link to a Classic Report using SQL and HTML, complete with best practices and examples.
How to Do It: Step-by-Step
-
Create or Edit a Classic Report Region
Navigate to your APEX app and create a new Classic Report page, or open an existing one. -
Edit the SQL Query
Modify the SQL query of the Classic Report to include a column with the desired link using HTML anchor (<a>
) tags.Example:
SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, '<a href="f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || '">View</a>' AS EMP_LINK FROM EMPLOYEES
This example creates a "View" link that navigates to Page 10 and passes the
EMPLOYEE_ID
as a value to page itemP10_EMPLOYEE_ID
. -
Set Column Type to "Standard Report Column"
In Page Designer, select theEMP_LINK
column in the report. In the Property Editor, set the "Escape Special Characters" option to No so the HTML anchor tag is rendered correctly in the browser. -
Configure Target Page (Optional)
On the target page (Page 10 in the example), make sureP10_EMPLOYEE_ID
is configured to receive the value via a page item or process.
Best Practices
-
Always validate and sanitize dynamic values (e.g.,
EMPLOYEE_ID
) to prevent injection attacks. -
Set “Escape Special Characters” to No only for columns where you control the output and have added safe HTML.
-
Use
f?p
syntax for links when navigating within APEX applications to preserve session context. -
Consider using dynamic actions or link icons if users expect a more interactive experience.
-
Keep page and item names consistent to simplify debugging and maintenance.
Useful Variations
-
Open the target page in a dialog:
'<a href="javascript:apex.navigation.dialog(' || '''f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || ''');">View</a>' AS EMP_LINK
-
Add multiple links (Edit, Delete):
'<a href="f?p=&APP_ID.:10:&SESSION.::NO::P10_EMPLOYEE_ID:' || EMPLOYEE_ID || '">Edit</a> | ' || '<a href="f?p=&APP_ID.:11:&SESSION.::NO::P11_EMPLOYEE_ID:' || EMPLOYEE_ID || '">Delete</a>' AS ACTIONS
Step 1 – We’re starting with an CUSTOMER table with 3 columns
Customer_ID
Full_Name
Email_Address
Step 2 – We are going to create a blank page with a custom report in it, added manually.
In this case is called: ClassicReport_ReportPage
Step 3 – Add region to the page and change it to a type of: Classic report Region. and wire it up to the Customer data table.
Step 4 – In the Classic report, navigate to the “Columns”, right click, and select “Add virtual column”.
Step 4 – Make the following changes
Step 5 – Lets create the Form that will receive our data. Create a Form.
Select the primary Key
You should now have something like this
Notice that in this case P41_CUSTOMER_ID is the key of the table
Step 6 – Go back to the Classic Report page. In this case it happens to be page 40 and our form page is page 41.
Navigate to the Link column and Edit the LINK area and click on the button.
Step 7 – Add the page number of the Form page (in this case is 41) and in the “Set Items” area, click on the hamburger list button.
Select the item that you want to pass “to” the Form page, in this P41_Customer_ID
Next select the Value that you want to pass. In this case the CUSTOMER_ID column’s value (the table’s primary key)
It should now look like this.
Save the page and view in the browser.
We now have a page with a column but no actual link
Step 8 –
In the link area, in the Link Text, enter a name, save, and review in browser.
Your page should now have a link that will navigate to the Form page
Step 9 – lets change to the words into a link. Select the hamburger next to the LinksText area and click on the fa-edit icon selection (or one of the other options) and save and review in browser.
You now have a navigational icon for the link area
You can read more on Classic Report customization and column linking in the official APEX documentation:
https://docs.oracle.com/en/database/oracle/apex/
Conclusion
Manually adding a link to a Classic Report in Oracle APEX is a simple yet powerful technique. It allows for full control over how users interact with your data, particularly when the default column link settings don't meet your needs. By using HTML inside SQL queries and configuring your report settings correctly, you can create dynamic, user-friendly applications that respond precisely to user actions.
No comments:
Post a Comment