To create an Interactive Report that displays Employees and their Departments, the most efficient way is to use a SQL JOIN. This allows you to show the department name instead of just a numeric ID, making the report much more readable.
Here are the detailed steps to build this in Oracle APEX.
Step 1: Prepare the SQL Query
First, you need a query that pulls data from both tables. We will use a LEFT JOIN to ensure employees appear even if they aren't assigned to a department yet.
SELECT
e.empno,
e.ename AS employee_name,
e.job,
e.hiredate,
e.sal AS salary,
d.dname AS department_name,
d.loc AS location, (e.sal + NVL(e.comm, 0)) AS total_compensation,
FROM emp e
LEFT JOIN dept d ON e.deptno = d.deptno
Step 2: Create the Report Page
Log in to your App Builder and select your application.
Click Create Page.
Select Component and then choose Report.
Select Interactive Report.
Page Attributes: Give your page a name (e.g., "Employee Directory").
Source:
Location: Local Database
Type: SQL Query
SQL Query: Paste the SQL code from Step 1.
Click Create Page.
Step 3: Enhance the UI (Page Designer)
Once the page is created, use Page Designer to make it look professional:
1. Format the Salary (Currency)
In the Left Pane (Rendering Tree), expand Columns.
Select the SALARY column.
In the Right Pane (Attributes), find Appearance > Format Mask.
Choose a currency format like
$999G999G999G999G990D00.Select TOTAL_COMPENSATION under the Columns folder.
In the Appearance section, set the Format Mask to a currency style (e.g.,
$999G999G999G990D00).(Optional) Change the Heading to "Total Comp".
2. Creating a "Virtual" Column (Alternative)
If you don't want to change your SQL query, you can also create a Computation directly within the Interactive Report as an end-user:
Run the page.
Click Actions > Data > Compute.
Column Label: Total Pay
Format Mask: $5,249.10
Expression:
I + J(where I is Salary and J is Commission).Click Apply.
3. Add a Highlight for High Earners
You can pre-configure the report to highlight certain data:
Run the page.
Click the Actions button on the report.
Select Format > Highlight.
Name: High Salary
Background Color: Light Green
Condition:
Salary>3000Click Apply.
Step 4: Add "Breadcrumbs" or Links
If you want users to click an employee name to see more details:
In Page Designer, select the EMPLOYEE_NAME column.
Change Identification > Type to Link.
Under Target, click No Link Defined.
Set the Target to a "Form" page you’ve created for employees, passing the
EMPNOas a parameter.
Summary of Benefits
By using an Interactive Report for this:
Users can group by
DEPARTMENT_NAMEto see a breakdown of staff.Managers can filter by
JOB(e.g., "CLERK" or "MANAGER").Everyone can export the list to Excel or PDF using the Actions > Download menu.
Comments
Post a Comment