Oracle® Database 2 Day + Application Express Developer's Guide Release 3.2 Part Number E11946-01 |
|
|
View PDF |
In this tutorial, you create a Human Resources (HR) application for a fictitious company called AnyCo Corp. This section shows you how to build the application, modify it, and preview it at different points during the development process.
Before you begin this section:
Ensure you have installed the database objects as described in "Installing the Sample Objects". This applies to both the hosted demo environment and local instance.
This section contains the following topics:
This tutorial guides you through the development of a Human Resources (HR) application for a fictitious company called AnyCo Corp. The application enables users to view and modify employee information stored in the OEHR_DEPARTMENTS
and OEHR_EMPLOYEES
tables.
When building the application, you perform these tasks:
"Creating the Initial Application": Create an application that includes a Home page and a basic Departments report.
"Using an Interactive Report": Run and use the Interactive Report.
"Modifying the Departments Report": Expand the report to pull in data from other tables.
"Adding an Employees Report and Form": Build an Employee form and report based on the OEHR_EMPLOYEES
table.
"Editing the Employees Report": Add calculated fields to the Employees report.
"Adding a Link on the Home Page to the Employees Report": Add a link on the Home page.
"Adding a Department Column to the Employees Reports": Modify the Employees report to enable the user to select a department.
"Linking a Column Value to Another Page": Add a link on the Departments report that navigates the user to the Employees report.
"Adding a Conditional Department Details Report": Add a report as a region that displays department details.
"Adding Your Company Name": Add your company name so that it appears on all pages in your application.
"Switching Themes to Change the User Interface": Switch the theme for your application.
This first exercise guides you through creating your initial application. Using the Create Application Wizard, you create two pages and specify basic application functionality.
The pages created in this section include:
Home - This page is the first page displayed when the application is run. This page contains a link to the Departments report.
Departments - This page is an interactive report of all departments.
There are two types of reports, interactive and classic. Interactive is the default when creating applications, converting forms and creating report regions. Interactive reports should be selected when you want to provide user customizations such as filters, sorting, compilation and so on. If you have limited need for this functionality, you are best served by using a classic report.
See also:
For more information on the difference between these two report types, see Chapter 3. How to Create a Parameterize Report in the Oracle Application Express Advanced Tutorials.To create your initial application:
Log in to Oracle Application Express.
For instructions, see "Logging In to the Hosted Demo Environment" or "Logging In to Your Local Instance".
On the Workspace home page, click Application Builder.
Click the Create button.
The Create Application Wizard appears.
Note that each page within a wizard displays the title of the wizard (for example, Create Application). Each wizard page also displays a series of blocks on the left, representing the sequence of steps. The highlighted block indicates the step you are performing.
To orient you, each step in these exercises generally begins with the block label. For example, the first step in the Create Application Wizard highlights the word Method. Therefore, the next step orients you by beginning with the words For Method.
For Method, accept the default, Create Application, and click Next.
For Name:
Name - Enter AnyCo Corp
.
Application - accept the default ID. The system provides a unique ID for each application you create in this workspace.
Create Application - Accept the default, From scratch.
Schema - Select the schema that contains the objects for this tutorial (for example, TWODAYPLUS).
Click Next.
Next, add a page to your application.
For Pages, specify the following in the Add Page section:
Select Page Type - Accept the default, Blank.
Tip:
Explanatory information for each option appears on the right side of the page. This page-level help appears throughout the application.Page Name - Enter Home
.
Click Add Page.
The Home page is now listed in the top area. Also, note that the Add Page area appears so you can continue adding pages to your initial application.
Next, add a report page on the OEHR_DEPARTMENTS
table.
In the Add Page section, specify the following:
Select Page Type - Select Report.
Subordinate to Page - Select Home (1).
This sets up the hierarchy among the pages in your application.
Page Source - Accept the default, Table.
Table Name - Select OEHR_DEPARTMENTS.
The list shows all tables and views in the schema associated with the application.
Click Add Page.
Notice that the pages listed in the Create Application section reflect the hierarchy of the pages in your application.
Next, change the default page name, OEHR_DEPARTMENTS, to Departments.
Click the Oehr_Departments link.
Under Page Definition, change the Page Name to Departments
and click Apply Changes.
In the Create Application section, click Next.
After adding your initial pages, define some application-level settings.
For Tabs, select No Tabs and click Next.
For Shared Components, accept the default, No, and click Next.
For Attributes, make these changes:
Authentication Scheme - Accept the default, Application Express.
Note that Application Express is the default Authentication Scheme. The authentication scheme option enables you to control users' access to the application using Application Express authentication or another type of authentication.
Language - Accept the default, English (United States) (en-us)
User Language Preference Derived From - Accept the default, Use Application Primary Language.
Date Format - Select the up arrow to select the 12-JAN-04 format from the list of Date formats.
Click Next.
For User Interface, select Theme 18 and click Next.
For Confirm, verify the information and click Create.
The two pages you created, Home and Departments, appear as icons by default.
Note:
To view the pages in a list instead of as icons, from the View list select Details and click Go. Your view setting is retained from session to session.Because these steps use the default setting, switch back to Icons view before continuing.
Notice that Oracle Application Express adds a Login page automatically to your application.
Congratulations! You created your first application using Oracle Application Express. Next, preview the application to see the application the way it would appear to end users.
You preview your application by running it. Running the application displays the rendered version of the application as end users would see it.
As you create pages, you can view them by running the page individually or by running the entire application. When you run a page or application, the Application Express engine dynamically renders it into viewable HTML based on data stored in the database.
To run the application, click the Run Application icon.
To run the page, click the Run Page icon.
To preview your application:
On the Application home page, click Run Application.
The first time you run an application you are prompted to enter a user name and password. To continue, simply enter your workspace user name and password and then click Login.
The first time you run an application you are prompted to enter a user name and password. To continue, simply enter your workspace user name and password and then click Login.
You can run the application using your Application Express login credentials because you chose Application Express Authentication when creating the application. For more information, see "Establishing User Identity Through Authentication" in Oracle Application Express Application Builder User's Guide.
The Home page of your application appears.
Notice that a link to the Departments page appears on the Home page because you set up that hierarchy.
Also notice the Developer toolbar at the bottom of the page. These links appear when you run an application within the development environment. The Developer toolbar offers a quick way to edit the current page, create a page, region, or page control, view session state, or toggle in and out of Debug mode.
Click the Departments link.
The Departments report appears.
When you run the Create Application Wizard, the wizard creates forms and reports based on the selections you make. Behind the scenes, Application Express writes a query for you to extract the appropriate data from the database.
In this exercise, you modify the query for the Departments report to include information from the OEHR_EMPLOYEES
table. Three columns from the OEHR_EMPLOYEES table, Number of Employees, Manager Name and Location, are added to the Departments report. The Manager Name column replaces the Manager Id column and the Location column replaces the Location Id column.
To modify the Departments report:
Click the Edit Page 2 link on the Developer toolbar (at the bottom of the page).
The Page Definition for Page 2 appears. A page is the basic building block of an application. Pages contain user interface elements such as tabs, lists, buttons, items, and regions. To see the definition of each page belonging to your application, you use the Page Definition page. For more information, see "What Is Application Builder?".
Under Page Rendering, locate the Regions section.
Click Departments.
Scroll down to Source, and replace the default Region Source script with the following:
SELECT d.DEPARTMENT_ID, d.DEPARTMENT_NAME, (select count(*)from oehr_employees where department_id = d.department_id) "Number of Employees", substr(e.first_name,1,1)||'.'||e.last_name "Manager Name", c.COUNTRY_NAME "Location" FROM OEHR_DEPARTMENTS d, OEHR_EMPLOYEES e, OEHR_LOCATIONS l, OEHR_COUNTRIES c WHERE d.LOCATION_ID=l.LOCATION_ID AND l.COUNTRY_ID=c.COUNTRY_ID AND d.DEPARTMENT_ID=e.department_id AND d.manager_id=e.employee_id AND instr(upper(d.department_name),upper(nvl(:P2_REPORT_SEARCH,d.department_name)))>0
Click Apply Changes.
Click Apply Changes to confirm.
Under the Regions section, click the Interactive Report link.
Click Edit icon next to Number of Employees.
Under Column Definition, select center for Column Alignment.
Click Apply Changes.
To see how the page looks to end users, run the page. When you run a page, the Application Express engine dynamically renders and processes the page to display viewable HTML.
To run the page:
Click the Run Page icon in the upper right corner.
The revised Departments report appears.
To add the new columns, click the Actions menu. The list of Action options appears.
Note that the Manager Id and Location Id columns are no longer available. Also note that the three new columns are not displayed on the revised report: Number of Employees, Manager Name, and Location. The following steps are required to add these columns to the display and reorder them.
Select Select Columns.
The columns that were added by the new SQL, Location and Manager Name, are in the Do Not Display box.
Click the Move All icon to add these three columns to the Display in Report box. The Move All icon looks like the following figure.
Description of the illustration bldap_moveall.gif
Use the up and down arrows to the right of the Display in Report to put the columns in this order:
Click Apply.
The Departments page appears and includes the new columns.
This exercise guides you through some commonly used report options available to users when they run interactive reports. These options allow the user to perform certain tasks quickly.
See Also:
For an overview of all Interactive Report components see How to Create a Parameterized Report in the Oracle Application Express Advanced Tutorials.Topics included in this section:
You already used the Select Column option from the Actions menu to add columns to the report display. In this section, you run the application and use some of the various search, sort, highlight and reset features to manipulate the Departments interactive report.
This tutorial only touches on some of the most prominent functionality available with interactive reports. For complete details refer to the Oracle Application Express Advanced Tutorials and Oracle Application Express Application Builder User's Guide.
If the report settings are not saved as the default, the columns added to the display in the previous steps are not displayed when the application is restarted or when the report is reset.
To save current report settings as the default:
Select the Actions menu.
Select Save Report.
The Save Report settings appear.
Select As Default Report Settings from the Save drop down.
Click Apply.
The report will show all columns when the user selects the Reset option from the Actions menu or when the page is reset by a Reset Interactive Report command, RIR
.
See Also:
For a description of how to save as a report as a Named Report see How to Create a Parameterized Report in the Oracle Application Express Advanced Tutorials.This exercise shows you how a user can add a filter to the Departments report. This example creates a filter to show all departments with the exception of departments with an Id of 60
.
There is more than one way a user can create a filter. The user can add a filter from the:
Search Bar
Actions Menu
Column Heading
The Actions menu offers more options than the others. For a quick filter using the equals operator, the Search Bar or column heading are the quickest methods. For anything else, use the Filter option from the Actions menu.
To create a filter for all departments not equal to 60
:
Select the Actions menu.
Select Filter.
The filter settings display. Note the user can also click the column heading link to create a filter for that column. Creating a filter from the column heading menu, however, is limited to the equal operator.
From the Operator drop down, select the not equals operator:
!=
Select 60 from the Expression drop down.
Click Apply.
The Departments report is displayed with the Department_Id!=60 filter applied. All departments, accept for the IT department with a Department Id of 60, are included in the report.
Notice the filter is shown at the top of the report. You can edit, disable, or delete this filter. To edit, click on the filter name. To disable, uncheck the check box. To delete, click on the Delete icon that looks like an X over the filter icon.
Uncheck the check box next to the Department Id!=60 filter to disable it.
The report shows data for all Department Ids.
In this exercise, you learn how the user can reorder the data for each column.
To change the sort order:
Select the Actions menu.
Select Sort.
The sort settings are displayed. Note this option is also available for each column by clicking the column heading. The Actions menu is quicker when changing the sort order for multiple columns.
Select Department Name for the first column entry.
Click Apply.
The report shows the Department Name column in ascending alphabetical order.
Notice the up arrow icon after the Department Name that indicates the column has been sorted in ascending order. You can click on this arrow to resort the column.
Another Actions menu option the user can select to reformat the report, is the controlled break. This allows the user to delineate data into clearly visible groups.
To add a controlled break:
Click the Location column heading.
The column heading menu appears.
Click the Control Break icon as shown below.
Note this same option is also available from the Actions menu.
The report is reformatted to show a break after each group of rows that share the same location.
Note the Location control break report setting has been added under the Department Id!=60 filter.
The user can display details for a row by selecting the Single Row icon.
To display the single row view:
Locate the Single Row View icon for the first row.
Select the Single Row View icon for the first row.
The details page for the first row appears.
The user can revert the report settings back to the saved default settings.
When an interactive report is reset, the default settings are applied to the report. An interactive report can be reset by the user and by the developer under the following conditions:
A user can reset an interactive report if the Reset option is available from the Actions menu. This option is enabled or disabled by the developer. For further details see "Editing Interactive Reports" in the Oracle Application Express Application Builder User's Guide.
A developer can specify that an interactive report be reset when it is called from another page. The Reset Interactive Report command, RIR
, is used for this purpose. For further details see "Editing Interactive Reports" in the Oracle Application Express Application Builder User's Guide.
To return to the default settings:
Select the Departments breadcrumb.
Select the Actions menu.
Select Reset.
Click Apply.
The report goes back to the default report settings saved in the previous section.
In this exercise, you add a report to display employee information and a form to create, update, and delete employee information.
To add an employee report and form:
Click the Application ID link on the Developer toolbar (at the bottom of the page).
The Application home page appears.
Click Create Page.
For Page:
Select Form and click Next.
Select Form on a Table with Report.
This option creates two pages, a report and form, based on a single table or view.
Click Next.
For Table/View Owner, accept the default and click Next. This specifies the schema owner.
For Table/View Name, select OEHR_EMPLOYEES and click Next.
For Define Report Page, make these changes:
For Define Report Page, accept the default, Do not use tabs, and click Next.
For Define Report Page, press the Ctrl key, select the following columns, and click Next:
EMPLOYEE_ID
FIRST_NAME
LAST_NAME
HIRE_DATE
SALARY
COMMISSION_PCT
The columns you selected appear on the Report page when the page is run.
For Define Report Page, accept the defaults and click Next.
Note that the default Edit Link image resembles a small piece of paper and pencil.
Next, define the page and region information for the form.
For Define Form Page, edit the following:
Page Name - Enter Create/Edit Employee
.
Region Title - Enter Create/Edit Employee
.
Entry Name - Enter Create/Edit Employee
.
Click Next.
In Primary Key, accept the defaults and click Next.
In Define the source for the primary key columns, accept the default, Existing trigger, and click Next.
Your table, OEHR_EMPLOYEES
, already has a trigger that populates the primary key.
In Select Column(s), select all columns and click Next.
These columns appear in the Create/Edit Employee form when the page is run.
In Identify Process Options, accept the defaults and click Next.
These selections enable users to add, update, and create employee records.
For Confirm, verify the information and click Finish.
To preview the two pages you just created, run the current page. From the Employees report, you can then preview the form.
To preview the pages:
Click the Run Page icon.
The Employees report appears.
Note the following about the Employees report:
The Search Bar with the Actions menu appears at the top. For more information see Using an Interactive Report .
The column headings are links that allow the user to quickly perform various sorting, filtering and reformatting operations. For more information see Using an Interactive Report .
The Edit icon you selected appears in each row. You can click the Edit icon to update the employee record. Since you created a form based on a table with a report, the wizard automatically linked the report to the form. If you create just a report, as is done in the previous Creating the Initial Application section, the wizard automatically links the report to the single row view.
The Create button appears in the upper right corner. You can click the Create button to add an employee to the underlying table.
The Employees report includes the five columns you specified. When you selected the columns and applied the changes, Oracle Application Express created the appropriate SQL code in the background to produce this result.
Your data might appear in a different order. If so, ignore this difference and continue with these steps.
To review the form you also created, click the Edit icon in an Employee row.
The Create/Edit Employee form appears.
Note the following about the Create/Edit Employee form:
The form includes Cancel, Delete, and Apply Changes buttons.
The Hire Date field displays a calendar, which is included because the data type of the underlying column is DATE
.
Fields labeled in red require entries.
In this exercise, you create a new column titled Remuneration to display employees' salaries in the Employees report.
Topics in this section include:
First, create a function to calculate employees' salaries.
To create a function:
Click the Home link on the Developer toolbar.
Click SQL Workshop and then SQL Commands.
SQL Commands provides a window where you can run PL/SQL against the database.
In the SQL editor, enter the following script:
CREATE OR REPLACE FUNCTION calc_remuneration( salary IN number, commission_pct IN number) RETURN NUMBER IS BEGIN RETURN ((salary*12) + (salary * 12 * nvl(commission_pct,0))); END;
When copying and pasting this SQL, make sure there is not an empty line before the first statement, CREATE OR REPLACE FUNCTION.
Click Run.
The Results section displays this message:
Function created.
Next, add a column to display the results of the employees' salary calculations.
To add a column:
Navigate to the Page Definition for page 3:
Click the Application Builder tab.
Select the AnyCo Corp application.
Click 3 - Employees.
The Page Definition for page 3, Employees, appears.
Under Regions, click the Employees link (next to Interactive Report).
Scroll down to Source, and replace the existing code with the following:
SELECT "EMPLOYEE_ID", "FIRST_NAME", "LAST_NAME", "HIRE_DATE", "SALARY", "COMMISSION_PCT", calc_remuneration(salary, commission_pct) REMUNERATION FROM "#OWNER#"."OEHR_EMPLOYEES"
Click Apply Changes.
Click Apply Changes to confirm.
To preview the page, click the Run Page icon in the upper right corner. Notice the Remuneration column does not appear. You must add the column by using the Select Column action.
To display the Remuneration column:
Select the Actions menu.
Select the Select Columns action.
Move the Remuneration column from the Do Not Display box to the Display in Report box.
Click Apply.
The Employees Report is displayed and includes the Remuneration column.
Next, change the format of the columns that contain numeric values.
To change the column format:
Click Edit Page 3 on the Developer toolbar (at the bottom of the page).
The Page Definition appears.
Under Regions, click Interactive Report.
The Interactive Report Attributes page appears.
Locate the Column Attributes section.
Next, change the format of the value in the Salary and Remuneration columns.
To edit the Salary format:
Click the Edit icon next to SALARY
.
For Number/Date Format, select $5,234.10 from the list.
Notice that the appropriate format mask appears in the field.
Click Apply Changes.
Repeat the previous step for REMUNERATION
.
Click the Run Page 3 icon in the upper right corner to preview the page.
Notice that the numbers in the Salary and Remuneration columns now appear with the dollar sign, include commas and decimals, and are correctly aligned.
In this exercise, you add a link on the Home page to take users to the Employees report. This link appears in the Navigation region on the left side of the Home page.
To add a link on the Home page to the Employees report:
Navigate to the Page Definition for the Home page, page 1:
Click Application in the Developer toolbar (at the bottom of the page).
On the Application home page, click Home.
Under Regions, click the List link (next to Navigation).
On the List Entries page, click the Create List Entry button on the right side of the page.
On the Create/Edit List Entry page, edit the following:
Sequence - Change to 20
.
List Entry Label - Enter Employees
.
Page - Enter 3
.
Click Create.
Run the page.
Notice that your Home page now includes a link to Employees.
Click Employees to test the link. The Employees report appears.
In this exercise, you link the Employees and Departments reports. When you complete this section, the Employees report will have a Departments column showing which department each employee belongs to.
To perform this task, you create a column on the Employees page to enable the user to select a department. You then run the Employees report and add the Departments column to the report display. The report settings are saved as the default.
Topics in this section include:
In order to filter the Employees report by department, add a Department column to the report.
To add a column:
Click on Edit Page 3 in the Developer toolbar.
Under Regions, click Employees and scroll down to Source.
Replace Region Source with the following SQL:
SELECT e.EMPLOYEE_ID, e.FIRST_NAME, e.LAST_NAME, e.HIRE_DATE, e.SALARY, e.COMMISSION_PCT, calc_remuneration(salary, commission_pct) REMUNERATION, e.DEPARTMENT_ID, d.DEPARTMENT_NAME FROM OEHR_EMPLOYEES e, OEHR_DEPARTMENTS d WHERE e.DEPARTMENT_ID=d.DEPARTMENT_ID
Click Apply Changes.
Click Apply Changes to confirm.
The next section explains how to add the column to the report display and how to use this column to filter employee reports.
When you first run this report, use the Select Columns action to add the Department Name column to the display. Once this column is visible on the report, make this report the default and filter by department.
To add the Department Name column to the report:
Click Run Page 3 icon.
Select the Actions menu and select Select Columns from the list.
Move the Department Name
from the Do Not Display box to the last entry in the Display in Report box.
Description of the illustration bldap_deptcol.gif
Click Apply.
The Employees Report is displayed and includes the Department Name column.
Next, make these report settings the default.
This section describes how to save the current report settings as the default. Report settings are any setting made through the Actions menu including: selected columns, filters, sorting, control breaks, highlights, computed columns, aggregate columns, charts, flashback.
In this example, the default settings include the display of all columns with no additional Actions menu settings such as filters, sorting, highlights and so on in the report. Once the default settings are saved, these columns are the default display in this report:
Employee Id
First Name
Last Name
Hire Date
Salary
Commission Pct
Remuneration
Department Name
To save the current report settings as the default:
Run the Employees report page.
The current report default does not include the Department Name column when the report is displayed.
Click the Actions menu.
Select Save Report from the list.
For Save, select As Default Report Settings from the list.
Click Apply.
Note:
If a reset is performed on this page, these default report settings are used. The Department Name column is displayed by default.In this exercise, you add a link to the Number of Employees column on the Departments report that navigates the user to the Employees report. It also sets the focus to the selected department. The column link includes a Clear Interactive Report command, CIR
, to clear the Employees report, when shown, of any filters, control breaks, highlights, aggregates, computed columns, chart settings and flashback settings.
Topics included in this section:
To make this change, you edit the report attributes on the Departments report to change the value for the Number of Employees column to a link.
To change the column value to a link:
Navigate to the Page Definition for the Departments page, page 2.
Under Regions, click Interactive Report.
The Interactive Report Attributes page appears.
Locate the Column Attributes section.
In the Column Attributes section, click the Edit icon next to Number of Employees.
Scroll down to the Column Link section.
Under Column Link, make these changes:
Page - Enter 3
.
Select the Reset Pagination check box.
Clear Cache - Enter 3,CIR
The 3
means the cache for page 3 is cleared and the string CIR
clears the Employees interactive report of any filters, control breaks, highlights, aggregates, computed columns, chart settings or flashback settings when the report is displayed.
Note:
If you want to reset the interactive report to the default report settings instead of clear the report, replaceCIR
with RIR
. The last saved default report settings are applied to the interactive report.Item 1, Name - Enter IR_DEPARTMENT_ID.
By prefixing the item name with IR_, the URL item will be associated with an interactive report column rather than an item on the page.
Item 1, Value - Select #Department ID#.
The Column Link section shows all the options you selected.
In summary, these options enable the following behavior when the end user clicks the link:
The end user is navigated to page 3, the Employees report.
On the Employees report, the selected department is in focus.
The Employees report is cleared. This means any filters, control breaks, highlights, aggregates, computed columns, chart settings or flashback settings are removed.
The user is returned to the first set of employee records when the user selects another department.
Click Apply Changes.
Note that in the Column Attributes section, the Number of Employees row contains a check mark in the Link column, reflecting the change you just made.
Now it's time to run the report and test the Number of Employees column link from the Departments report. The Employees report is displayed showing all employees that belong to the selected department.
Click the Run Page 2 icon.
The Departments report is displayed. Note that end users can now drill down on the data in the Number of Employees column.
In the Number of Employees column, click the 3
for the Executive row.
All employees that belong to the Executive department appear in the Employees report.
The Department Id filter is displayed because this report is filtered by the Department Id value for the Executive department, 90
, passed to this report from the Departments report. Notice the Clear Interactive Report command is included at the end of the URL in your browser, as shown in this example:
f?p=9257:3:3672543193352902::NO:RP,3,CIR:IR_DEPARTMENT_ID:90
This exercise demonstrates how to use the CIR command to clear a highlight before displaying the Employees report. To show this, you highlight any rows containing the first name of Neena, then display the Employees report from the Number of Employees column on the Departments report.
To highlight rows in the Employees report:
Click the Actions menu and select Highlight.
The Highlight options appear.
For Highlight options make these changes:
Name - Enter Neena
Background Color - Select [yellow]
Text Color - Select [blue]
Column - Select First Name
Operator - Select =
Expression - Select Neena
Click Apply.
The Employees report appears with the row for Neena highlighted.
Click the Home breadcrumb.
Click Departments link.
Click Number of Employees in the Executive row.
The Employees report is displayed with the highlighting cleared, due to the CIR
command specified in the column link.
In this exercise, you add a report as a region that displays department details. You also create a condition so that the report displays department information only if you select a department. If you select No Department Assigned, the Department Details report does not appear.
Topics in this section include:
First, create the report and set it to conditionally display.
To create the report and condition:
Navigate to the Page Definition for page 3, Employees.
Under Regions, click the Create icon.
For Region, make these changes:
Identify the type of region to add to this page - Select Report and click Next.
Report Implementation - Accept the default, SQL Report, and click Next.
For Display Attributes, make these changes:
Title - Enter Department Details
.
Region Template - Select No Template.
Sequence - Enter 7
.
Accept the remaining defaults and click Next.
For Source, make this change:
Enter the following query:
SELECT count(e2.employee_id) "Number of Employees:", substr(e.first_name,1,1)||'. '|| e.last_name "Manager Name:", c.country_name "Location:" FROM oehr_departments d, oehr_employees e, oehr_locations l, oehr_countries c, oehr_employees e2 WHERE d.manager_id = e.employee_id AND d.location_id = l.location_id AND d.department_id = e2.department_id AND l.country_id = c.country_id AND nvl(d.department_id,'-1') = nvl(:P3_DEPARTMENT_ID,'-1') GROUP BY substr(e.first_name,1,1)||'. '||e.last_name, c.country_name
Click Next.
Next, you create a condition that does not display department details when the user selects the No Department Assigned option.
For Report Attributes, make these changes:
Report Template - Select default: vertical report, look 1 (include null columns).
This selection displays the list vertically.
Accept the remaining defaults and click Next.
For Conditional Display, make these changes:
Condition Type - Select Value of Item in Expression 1 != Expression 2.
Note the exclamation point (!) included after Expression 1 in the option to select.
Expression 1 - Enter:
P3_DEPARTMENT_ID
Expression 2 - Enter:
-1
The -1
indicates no Department has been assigned.
Click Create Region.
Under Regions, click Create icon.
Select HTML and click Next.
Select HTML and click Next.
For Create Region, make these changes:
Title - Enter Department
Region Template - Select No Template
Sequence - Enter 5
Click Create.
In this section, you create a list of values that is used to select which department details to view. This is a dynamic list that queries the OEHR_DEPARTMENTS table for a list of all the department names.
To create a list of values:
Click Shared Components icon at the top right next to the Run Page 3 icon.
Under User Interface, select Lists of Values.
Click the Create button.
Accept the default, From Scratch, and click Next.
For Name, enter DEPARTMENTS
and select Dynamic.
Click Next.
For the Query, enter the following SQL:
SELECT department_name d, department_id v FROM oehr_departments ORDER BY d
Click Create List of Values.
Now, you create an item in the Department Details region to display the list of departments.
To add an item:
Navigate to the Page Definition for page 3, Employees.
Under Items, click the Create icon.
Select Select List and click Next.
Select Select List with Submit and click Next.
For Create Item, make these changes:
Item Name - Enter P3_DEPARTMENT_ID
Sequence - Enter 10
Region - Select Department (1) 5
Click Next.
For Identify List of Values, make these changes:
Named LOV - Select DEPARTMENTS
Display Null Option - Select Yes
Null Text - Enter - No Department Assigned -
Null Value - Enter -1
Click Next.
For Label, enter Department
and click Next.
For Item Source Value, enter -1
Click Create Item.
You need to add a branch that returns to the Employees page 3 when the user chooses a department from the Department list of values.
Under Branches, click the Create icon.
Accept defaults and click Next.
For Page, enter 3
.
Select reset pagination for this page and click Next.
Accept defaults and click Create Branch.
Now, you change the Employees report query to display employees that belong to the selected department.
To change the query:
Under Regions, click the Employees link.
Enter the following SQL for Region Source:
SELECT e.EMPLOYEE_ID, e.FIRST_NAME, e.LAST_NAME, e.HIRE_DATE, e.SALARY, e.COMMISSION_PCT, calc_remuneration(salary, commission_pct) REMUNERATION, e.DEPARTMENT_ID, d.DEPARTMENT_NAME FROM OEHR_EMPLOYEES e, OEHR_DEPARTMENTS d WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID(+) AND (e.DEPARTMENT_ID = :P3_DEPARTMENT_ID or (e.DEPARTMENT_ID is null and nvl(:P3_DEPARTMENT_ID,'-1') = '-1'))
Click Apply Changes.
Because the Employees query has changed, the Number of Employees column link needs to initialize the P3_DEPARTMENT_ID item to the value of DEPARTMENT_ID.
To change the column link for Number of Employees:
Click the Application ID breadcrumb.
Click 2 - Departments.
Under Regions, click the Interactive Report link.
Click the Edit icon for Number of Employees.
Under Column Link, enter P3_DEPARTMENT_ID
for Item 1.
Click Apply Changes.
Next, turn off pagination for the Department Details report, because only one record (the department details report) displays at a time. If pagination is on, the region that displays the department details includes the information row 1 - 1.
To turn off pagination:
Click the Application ID breadcrumb.
Click 3 - Employees.
Under Regions, click Report (next to Department Details).
Scroll down to Layout and Pagination.
For Pagination Scheme, select - No Pagination Selected -.
Click Apply Changes.
Run the page.
To remove the Department id = 90 filter, select the Remove Filter icon next to the filter.
From the Department list, select No Department Assigned.
Employee Kimberely Grant appears. This employee is not currently assigned to a department. Therefore, no department details appear. The 1 - 1 you see on this form is part of the Employees report, not part of the Department Details region you just edited.
From the Department list, select Marketing.
Note the details under Department.
You can add a graphical logo or text to your application so that it displays on each page. Your page template determines the display location.
In this exercise, you add your company name to your application.
To add your company name to your application:
Navigate to the Application home page. Click the Application link on the Developer toolbar (at the bottom of the page).
Click Shared Components.
Under Application, click Definition.
The Edit Application Definition page appears.
Under Logo:
Logo Type - Select Text.
Logo - Enter AnyCo Corp
.
Logo Attributes - Select Black Text from the pop up list.
Click Apply Changes.
Click Application link on Developer toolbar.
Click Run Application icon.
The company name now appears on each page in your application.
In this exercise, you switch the current theme to another one for your application. A theme is a collection of templates that defines the application user interface. Each theme contains templates for every type of application component and page control, including individual pages, regions, reports, lists, labels, menus, buttons, and list of values.
Oracle Application Express separates presentation (or user interface themes) from the application logic. You can design your application in one theme, change to another supplied theme, or create and use your own custom theme. By separating the application logic (such as queries, processes, and branches) from the HTML rendering, your application can take advantage of the latest designs and other technological advances without an application rewrite. Each theme provides a complete set of templates that accommodate every user interface pattern that may be needed in an application.
To switch the theme:
Click the Application link on the Developer toolbar (at the bottom of the page).
On the Application home page, click Shared Components.
Under User Interface, click Themes.
On the Themes page, click Create.
The Create Theme Wizard appears.
For Method, accept the default, From the Repository, and click Next.
For Identify Theme, select Theme 11 and click Next.
For Confirm, click Create.
Click Switch Theme.
For Identify Theme, accept the default, 11. Round Green, and click Next.
For Verify Compatibility, review the information, accept the defaults, and click Next.
The wizard verifies that corresponding templates exist in the selected theme for all templates used in your current application. If a template is missing, it warns you with a message in the Status column. For this tutorial, you can ignore this message because Oracle Application Express maps missing region templates to existing ones.
For Confirm Switch, click Switch Theme.
Run the page.
The color scheme and display layouts are changed in all your pages.