Apex 3-2 Advanced Tutorials
Apex 3-2 Advanced Tutorials
Advanced Tutorials
Release 3.2
E13363-02
June 2009
Oracle Application Express Advanced Tutorials, Release 3.2
E13363-02
Copyright © 2003, 2009, Oracle and/or its affiliates. All rights reserved.
Contributors: Carl Backstrom, Amitabh Chhibber, Sharon Kennedy, Jason Straub, and Rekha Vallam
This software and related documentation are provided under a license agreement containing restrictions on
use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your
license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,
transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse
engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is
prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If
you find any errors, please report them to us in writing.
If this software or related documentation is delivered to the U.S. Government or anyone licensing it on
behalf of the U.S. Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data
delivered to U.S. Government customers are "commercial computer software" or "commercial technical data"
pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As
such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and
license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of
the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software
License (December 2007). Oracle USA, Inc., 500 Oracle Parkway, Redwood City, CA 94065.
This software is developed for general use in a variety of information management applications. It is not
developed or intended for use in any inherently dangerous applications, including applications which may
create a risk of personal injury. If you use this software in dangerous applications, then you shall be
responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure the safe use
of this software. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of
this software in dangerous applications.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks
of their respective owners.
This software and documentation may provide access to or information on content, products, and services
from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all
warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and
its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of
third-party content, products, or services.
Contents
Preface ................................................................................................................................................................. xi
Audience....................................................................................................................................................... xi
Documentation Accessibility ..................................................................................................................... xi
Related Documents .................................................................................................................................... xii
Conventions ............................................................................................................................................... xiii
iii
Adding a Filter to a Report ............................................................................................................ 3-12
Saving Report Settings and Selecting Columns.......................................................................... 3-14
Resetting to the Default Report Settings...................................................................................... 3-16
Related Documentation ....................................................................................................................... 3-16
iv
Adding a Region to Contain Hint Text.............................................................................................. 5-17
Changing Item Types ........................................................................................................................... 5-18
Change an Item to a Radio Group ................................................................................................ 5-18
Change an Item to a Select List ..................................................................................................... 5-19
Change an Item to a Check Box .................................................................................................... 5-20
About Label Templates ........................................................................................................................ 5-21
Changing Buttons.................................................................................................................................. 5-22
Running the Page for Update ............................................................................................................. 5-22
Making Data Bold ................................................................................................................................ 5-23
v
8 How to Create a Stacked Bar Chart
About the Syntax for Creating Chart Queries .................................................................................... 8-1
Creating an Application .......................................................................................................................... 8-2
Creating a New Page................................................................................................................................ 8-3
Adding Additional Series....................................................................................................................... 8-4
Updating the Sample Data ..................................................................................................................... 8-6
Viewing the Chart .................................................................................................................................... 8-6
Editing Chart Attributes ......................................................................................................................... 8-7
vi
Change the Item to a Select List .................................................................................................... 10-9
Create a Call to the disFormItems Function.............................................................................. 10-10
vii
Review an Existing Installation Script ................................................................................ 12-11
About Creating Installation Scripts from Files .................................................................. 12-12
About Creating Scripts to Install Files ................................................................................ 12-13
Success Message ............................................................................................................................ 12-14
About Supporting Objects Deinstallation ..................................................................................... 12-14
View the Deinstallation Confirmation Message....................................................................... 12-14
Review the Deinstallation Script................................................................................................. 12-15
View the Deinstallation Success Message ................................................................................. 12-15
About Supporting Objects Export ................................................................................................... 12-15
Review the Supporting Objects Export Setting ........................................................................ 12-15
Where the Export Default Appears When Exporting.............................................................. 12-15
About Creating Upgrade Scripts ...................................................................................................... 12-16
Utilizing Upgrade Messages ....................................................................................................... 12-16
About Refining Your Installation Scripts....................................................................................... 12-17
Downloading Public Packaged Applications and Sample Code............................................... 12-17
viii
Select Data Presentation Functions ....................................................................................... 14-3
Define Special Function Requirements................................................................................. 14-3
Designing the Database Objects ........................................................................................................ 14-4
About the Projects Table ................................................................................................................ 14-4
About the People Table .................................................................................................................. 14-5
About the Issues Table ................................................................................................................... 14-6
Implementing Database Objects........................................................................................................ 14-7
Additional Database Objects Needed .......................................................................................... 14-7
About Building Database Objects ................................................................................................. 14-8
Create and Run a Script to Build Database Objects ................................................................... 14-8
View the Created Database Objects.............................................................................................. 14-9
Loading Demonstration Data............................................................................................................ 14-10
ix
Add an Assign Open Issues Report Page .......................................................................... 15-56
Add an Issue Summary by Project Report Page................................................................ 15-60
Add Resolved by Month Identified Report Page.............................................................. 15-66
Add a Calendar to Display Target Resolution Dates ....................................................... 15-67
Add a Bar Chart to Display Average Days to Resolve..................................................... 15-72
Add a Dashboard Page................................................................................................................. 15-74
Overview of Dashboard Page .............................................................................................. 15-74
Create Dashboard Page ........................................................................................................ 15-75
Add An Overdue Issues Report........................................................................................... 15-76
Add an Unassigned Issues Report ...................................................................................... 15-78
Add a Recently Opened Issues Report ............................................................................... 15-79
Add an Open Issues by Project Pie Chart .......................................................................... 15-81
Adding Advanced Features ............................................................................................................... 15-82
Add Support for Email Notification........................................................................................... 15-82
How Email Notification Works ........................................................................................... 15-83
Add Notification of New Assignments .............................................................................. 15-83
Add Notification for Overdue Issues.................................................................................. 15-85
Add Application Security ............................................................................................................ 15-88
Restrict Project and People Definition ................................................................................ 15-88
Restrict Issue Modification ................................................................................................... 15-91
Deploying Your Application ............................................................................................................. 15-95
Move the Application Definition ................................................................................................ 15-95
Export the Application Definition ....................................................................................... 15-95
Create the Required Objects to Support the Application................................................. 15-96
Import the Application Definition into the Production Instance.................................... 15-96
Load the Data ......................................................................................................................... 15-97
Alternate Authentication Mechanisms to Consider................................................................. 15-97
Create Users ................................................................................................................................... 15-98
Publish the URL............................................................................................................................. 15-98
x
Preface
Audience
Oracle Database Application Express Advanced Tutorials is intended for application
developers who wish to learn how to build database-centric Web applications using
Oracle Application Express. To use this guide, you need to have a general
understanding of relational database concepts, the operating system environment
under which you are running the Oracle Application Express, and Application
Builder.
What is Application Builder? A component of Oracle Application Express, Application
Builder is a powerful tool that enables you to quickly assemble an HTML interface (or
application) on top of database objects such as tables and procedures. Prior to
completing these tutorials, please review Oracle Database 2 Day + Application Express
Developer's Guide.
Documentation Accessibility
Our goal is to make Oracle products, services, and supporting documentation
accessible to all users, including users that are disabled. To that end, our
documentation includes features that make information available to users of assistive
technology. This documentation is available in HTML format, and contains markup to
facilitate access by the disabled community. Accessibility standards will continue to
evolve over time, and Oracle is actively engaged with other market-leading
technology vendors to address technical obstacles so that our documentation can be
accessible to all of our customers. For more information, visit the Oracle Accessibility
Program Web site at http://www.oracle.com/accessibility/.
xi
Accessibility of Code Examples in Documentation
Screen readers may not always correctly read the code examples in this document. The
conventions for writing code require that closing braces should appear on an
otherwise empty line; however, some screen readers may not always read a line of text
that consists solely of a bracket or brace.
Related Documents
For more information, see these Oracle resources:
■ Oracle Database Application Express Installation Guide
■ Oracle Database Application Express Release Notes
■ Oracle Database 2 Day + Application Express Developer's Guide
■ Oracle Database Application Express User's Guide
■ Oracle Database Concepts
■ Oracle Database Application Developer's Guide - Fundamentals
■ Oracle Database Administrator's Guide
■ Oracle Database SQL Reference
■ SQL*Plus User's Guide and Reference
For additional application examples, please visit the Oracle by Examples (OBEs)
Application Express page, located on Oracle’s Technology Network. The OBEs
provide step-by-step examples with screenshots on how to perform various tasks
within Application Express.
http://www.oracle.com/technology/products/database/application_express/html/obes.html
For information about Oracle error messages, see Oracle Database Error Messages.
Oracle error message documentation is available only in HTML. If you have access to
the Oracle Database Documentation Library, you can browse the error messages by
range. Once you find the specific range, use your browser's "find in page" feature to
locate the specific message. When connected to the Internet, you can search for a
specific error message using the error message search feature of the Oracle online
documentation.
xii
Many books in the documentation set use the sample schemas of the seed database,
which is installed by default when you install Oracle. Refer to Oracle Database Sample
Schemas for information on how these schemas were created and how you can use
them yourself.
Printed documentation is available for sale in the Oracle Store at
http://oraclestore.oracle.com/
To download free release notes, installation documentation, white papers, or other
collateral, please visit the Oracle Technology Network (OTN). You must register
online before using OTN; registration is free and can be done at
http://www.oracle.com/technology/membership/
If you already have a user name and password for OTN, then you can go directly to
the documentation section of the OTN Web site at
http://www.oracle.com/technology/documentation/
Conventions
The following text conventions are used in this document:
Convention Meaning
boldface Boldface type indicates graphical user interface elements associated
with an action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for
which you supply particular values.
monospace Monospace type indicates commands within a paragraph, URLs, code
in examples, text that appears on the screen, or text that you enter.
xiii
xiv
1
About these Tutorials
Oracle Database Application Express Advanced Tutorials contains a series of tutorials that
explain how to use Oracle Application Express to create applications and application
components. The goal of this book is to help you understand how to use Oracle
Application Express through hands-on experience.
This section contains the following topics:
■ What this Book Is Not
■ Tutorial Topics
■ About Loading Sample Objects
■ About Application Authentication
Tutorial Topics
This document contains the following tutorials:
Title Description
How to Create a Tabular Form Illustrates how to create a tabular form within a new
application and how to change one of the updatable
columns from a text field to a select list.
How to Create a Parameterized Illustrates how to create an interactive report and explains
Report how a user can customize the report.
Title Description
Using Advanced Report Highlights some of the more advanced reporting
Techniques techniques, such as linking from one interactive
report to another and creating declarative filters
within a URL.
How to Control Form Layout Explains how to create a data input form and then change
the form layout by editing the region and item attributes.
How to Work with Check Boxes Illustrates the different ways in which you can create and
process check boxes within an application.
How to Implement a Web Explains how to call a Web service from within an
Service application.
How to Create a Stacked Bar Explains how to create a stacked bar chart within an
Chart application.
How to Upload and Download Illustrates how to create a form and report with links for
Files in an Application file upload and download.
How to Incorporate JavaScript Describes some usage scenarios for JavaScript and includes
into an Application details about how to implement them in your application.
How to Build an Access Control Explains how to build an Access Control Administration to
Page restrict access to an application.
How to Review a Packaged Explores the OEHR Sample Objects packaged application.
Application By reviewing the supporting objects behind this
application, you can learn how the Supporting Object
Utility works so that you can create your own packaged
applications.
How to Create a Master Detail Explains how to create a master detail form, define a report
PDF Report query and RTF template, and then create a button to
expose the new report.
How to Design an Issue Tracking This tutorial describes how to plan, design and populate
Application data objects for an example Issue Tracking application.
How to Build and Deploy an Provides step-by-step instructions on how to create and
Issue Tracking Application deploy an application that tracks the assignment, status,
and progress of issues related to a project.
associates product category, product descriptions, the weight group (for shipping
purposes), the warranty periods, the supplier, the status availability, and a
minimum price.
To create the objects locally in your workspace, you need to import the OEHR Sample
Objects application.
This section contains the following topics:
■ Downloading OEHR Sample Objects
■ Importing and Installing OEHR Sample Objects
■ Viewing Database Objects
5. To remove all associated objects and sample data, select Remove Application
Definition and Deinstall Supporting Objects.
6. Click Deinstall.
6. To search for an object name, enter a case insensitive term in the Search field.
7. To view all objects, leave the Search field blank.
A tabular form enables users to update multiple rows in a table at once from a single
page. You can use the Tabular Form Wizard to create a tabular form that contains a
built-in multiple row update process. This built-in process performs optimistic locking
behind the scenes to maintain the data integrity.
This tutorial explains how to create a tabular form within a new application and then
how to change one of the updatable columns from a text field to a select list. Before
you begin, you need to import and install the OEHR Sample Objects application in
order to access the necessary sample database objects. See "About Loading Sample
Objects" on page 1-2.
This section contains the following topics:
■ Creating an Application
■ Creating a Tabular Form Using a Wizard
■ Changing an Updatable Column to a Select List
For additional examples on this and related topics, please visit the following Oracle by
Examples (OBEs):
■ Oracle Application Express 3.0 - Building a Functional Application
http://www.oracle.com/technology/obe/apex/obe30/apexdev30.htm
Creating an Application
First, you need to create an application using the Create Application Wizard.
To create an application using the Create Application Wizard:
1. On the Workspace home page, click the Application Builder icon.
The Application Builder home page appears.
2. Click Create.
3. Select Create Application and click Next.
4. For Name:
b. Click Next.
7. For Primary Key, accept the default, EMPLOYEE_ID (Number) and click Next.
8. For Source Type, accept the default, Existing trigger, and click Next.
9. For Updatable Columns, select all columns and click Next.
10. For Page and Region Attributes:
2. If prompted to enter a user name and password, enter your workspace user name
and password and click Login. See "About Application Authentication" on
page 1-6.
The tabular form appears as shown in Figure 2–2 on page 2-4.
As shown in Figure 2–2, note that the tabular form contains four buttons. Cancel,
Delete, and Apply Changes display in the upper right corner and Add Row displays
in the bottom right corner. Additionally, a check box appears to the left of each row to
enable the user to select the current row. Users can also select all rows at once by
selecting the check box to the left of the column headings. The same check box is also
used in conjunction with the Delete button to identify the rows to be deleted.
Note that the overall form layout (that is, the color scheme, button placement, region
header placement, and so on) are controlled by templates in the currently selected
theme.
2. Under Column Attributes, click the Edit icon next to the DEPARTMENT_ID
column as shown in Figure 2–5. The Edit icon resembles a small page with a pencil
on top of it.
The Column Attributes page appears.
Next, change the default display of this column to a select list.
3. Scroll down to Tabular Form Element. From Display As, select Select List (named
LOV).
4. Scroll down to Lists of Values. From Named LOV, select DEPTID.
5. Scroll up to the top of the page and click Apply Changes.
6. Click the Run Page icon in the upper right corner of the page.
As shown in Figure 2–6 on page 2-7, notice the Department Id column now
displays as a select list.
Figure 2–6 Tabular Form with Department Id Column Changed to a Select List
report includes the ability to perform searching, filtering, sorting, column selection,
highlighting, and other data manipulations. For a complete list of capabilities and how
to use them, see "Using an Interactive Report" on page 3-10. See Figure 3–1 for an
example of an interactive report that queries the IT_PEOPLE table and was created
using the Create Page Wizard.
Notice the automatically built in Search Bar, Column Heading Menu links, and Link
Column icons in the first column of each row. For a complete description of each of
these components, see Introducing Interactive Report Components on page 3-10.
A classic report does not by default include any of the interactive report customization
features. See Figure 3–2 for an example of a classic report that was built with the
Create Page Wizard and queries the same columns in the IT_PEOPLE table as the
interactive report in Figure 3–1 queries.
Notice there is no search bar, no column heading links and no drill down capability.
d. CREATED_BY
e. MODIFIED_ON
f. MODIFIED_BY
10. Click Apply Changes.
12. Under Page Definition, enter Issue Details for Page Name.
15. For Tabs, accept the default, One Level of Tabs, and click Next.
16. For Copy Shared Components from Another Application, accept the default, No,
and click Next.
17. For Attributes, accept all defaults and click Next.
The Create Application Wizard configured the Issues interactive report Link
Column to target the Issue Details form. This is the default when the wizard
creates a page type of Report and Form.
4. Use the Move All arrows (>>) to move all columns from the Do Not Display box
to the Display in Report box.
5. Select the Issue Id column in the Display in Report box and click the Remove
arrow (<) to move it to the Do Not Display box.
6. Using the up and down arrows to the right of the Display in Report box, reorder
the columns as follows:
a. Issue Summary
b. Identified By
c. Identified Date
d. Project Name
e. Assigned To
f. Status
g. Priority
h. Target Resolution Date
i. Progress
Unless disabled by the developer, the following components are by default included
on an interactive report page:
■ Search Bar - Displays at the top of each interactive report page. Provides the
following features:
– Select columns icon looks like a magnifying glass and enables you to identify
which column to search (or all).
– Text area enables you to enter case insensitive search criteria (wild card
characters are implied).
– Rows selects the number of records to display per page.
– Go button executes the search.
– Actions Menu icon displays the actions menu.
■ Actions Menu - Used to customize the display of your interactive report. Provides
the following options:
– Select Columns specifies which columns to display and in what order.
– Filter focuses the report by adding or modifying the WHERE clause on the
query.
– Sort specifies which columns to sort on and whether the order is ascending or
descending.
– Control Break creates a break group on one or several columns.
– Highlight enables you to define a filter and highlight the rows that meet the
filter criteria.
– Compute enables you to add computed columns to your report.
– Aggregate enables users to perform mathematical computations against a
column.
– Chart adds a chart to your interactive report.
– Flashback performs a flashback query enabling you to view the data as it
existed at a previous point in time.
– Save Report saves the current customized report settings so they can be used
in the future.
– Reset enables you to reset the report back to the default report settings.
– Help provides detailed descriptions of how to use the interactive report
components to customize your reports.
– Download enables the current result set to be downloaded.
■ Column Heading Menu - Clicking on any column heading exposes a column
heading menu that enables you to change the sort order, hide columns, create
break groups on a column, view help text about the column and create a filter.
■ Report Settings - If you customize your interactive report, the report settings are
displayed below the Search Bar and above the report. If you save customized
reports, they are shown as tabs.
■ Link Column - This column links to a Single Row View or to a Custom Target. In
this particular interactive report, shown in Figure 3–12, "Interactive Report
Components", the link column is a Custom Target, displayed as an Edit icon, that
links to the Issue Details form enabling the user to view and modify the selected
issue information.
The Link Column is specified by the interactive report’s Link Column setting on
the Report Attributes page. There are three possible selections for this setting:
– Link to Single Row:
This option enables the user to view details for a single row. The Single Row
View enables the user to view data, not modify it. Link to Single Row is the
default setting when creating an interactive report of page type Report. See the
Issues interactive report page created in Chapter 4, "Using Advanced Report
Techniques" for an example.
– Link to Custom Target:
This option enables the user to go to another page in the application or to a
URL, depending on which target was specified by the developer. Link to
Custom Target is the default setting when creating an interactive report of
page type Report and Form. The target defaults to the form page where the
user can modify data for that row. The Issues interactive report in this
application is an example of this type of link.
– Exclude Link Column:
This option removes the Link Column from the interactive report.
Next, you examine some of these features to customize the appearance of your report
and specify what data to include.
Notice the filter Assigned To contains 'carla' has been added to the Report Settings
area above the report. You can edit, disable or delete the filter.
Next, you disable then enable the filter.
4. Click the Enable/Disable check box next to Assigned To contains 'carla' to
disable the filter (the check box is now unchecked).
The report is displayed showing all issues.
5. Click the Enable/Disable check box next to Assigned To contains 'carla' to once
again enable the filter (the check box is now checked).
The report is displayed showing issues assigned to Carla.
6. Click the Assigned To contains 'carla' link.
The Filter edit options are displayed.
Notice there are two tabs, the Working Report and Report 1 tabs. The Report 1 tab
highlighted in orange is the current report being displayed. You can customize
this report further and save your changes, as shown in the proceeding steps, or
you can select the Working Report tab and make changes there. Changes made to
the Working Report do not affect any of the saved reports.
You can edit the saved report tab by clicking the Saved Report = "Report 1" link in
the report settings area and making changes to the Save Report options.
Note: Because the Named Report is only for the current user who is
logged in, the capability to create a Named Report is only available if
the application or page is not publilc and has some sort of
authentication. See "Editing Interactive Reports" in the Oracle Database
Application Express User's Guide for further information.
You can also remove the saved report. Follow these steps to delete the saved report:
1. Click the Delete Report icon (it looks like a report with an X over it) next to the
Saved Report = "Report 1" link in the report settings area.
2. Click Apply.
The customized report with 5 columns appears with the saved report tabs
removed.
Congratulations, you now understand the Application Express reporting basics and
are ready to try Chapter 4, "Using Advanced Report Techniques".
Related Documentation
For additional information on this and related topics:
■ Interactive Report Online Help
■ Oracle Database Application Express Advanced Tutorials
"Using Advanced Report Techniques"
"How to Design an Issue Tracking Application"
"How to Build and Deploy an Issue Tracking Application"
■ Oracle Database 2 Day + Application Express Developer's Guide
"Building the Application"
■ Oracle Database Application Express User's Guide
"Editing Interactive Reports"
■ Using Interactive Report Regions (OBE)
http://www.oracle.com/technology/obe/hol08/apex31nf/apexusr31/apexusr31_otn.htm
In this tutorial, you create an application that highlights some of the more advanced
interactive reporting techniques.
The following procedures are described:
■ Augmenting the report to include data from other tables.
■ Adding a navigation link from the home page to an interactive report. S
■ Creating a column link from one interactive report to another.
■ Passing column values from one interactive report to another.
■ Querying an interactive report for column values.
This tutorial contains the following topics:
■ Create the Basic Application
■ Display People and Project Names
■ Add a Dashboard Page
■ Related Documentation
■ CRETATED_ON
■ CREATED_BY
■ MODIFIED_ON
■ MODIFIED_BY
10. Click Next.
12. For Shared Components, accept the default, No, and click Next.
4. Locate the Link Column icon for Issue Id 1 as shown in Figure 4–3, "Single Row
View Icon".
The Create Application Wizard configured the Issues interactive report Link
Column to display the Single Row View. This is the default when the wizard
creates a page type of Report.
6. Click the Application ID link on the Developer toolbar at the bottom of the page
to return to the Application home page.
Notice that the Create Application Wizard also created a Login page.
4. Highlight Identified By in the Do Not Display box and click the Move icon (>).
5. Repeat the previous step for Project Name, and Assigned To.
The only column left in the Do Not Display box is Project Id. All other columns
appear in the Display in Report list.
6. Click Apply at the bottom right of the Select Columns area.
Your Issues page should now look like Figure 4–7.
This link column includes a Clear Interactive Report command, CIR, to clear
the Issues interactive report of any filters, control breaks, highlights,
aggregates, computed columns, chart settings and flashback settings.The 2
clears the cache for the Issues report (page 2).
Note: If you want to reset the interactive report, replace CIR with
RIR (Reset Interactive Report). The RIR command resets the report to
the last saved default report settings.
The Name and Value settings create a declarative filter for the Issues
interactive report. The Project Name link passes the value of the Project Name
column to the Issues report. When the link is clicked by the user, the Issues
report displays all issues for that project, regardless of whether or not the issue
is overdue.
Notice the 'New Payroll Rollout' filter at the top of the report. The filter was
created when the user clicked the Project Name link column.
Notice the SELECT statement is sending a request to the Issues interactive report
page 2 asking for the number of issues that belong to a particular project name and
that have a status of Open. The CIR command is used to Clear the Interactive
Report to make sure all of the requested values are included in the query and have
not been filtered out or set as a column to not display.
9. For When No Data Found Message, enter No open issues.
10. Click Create Region.
2. On the pie chart, locate the Employee Satisfaction Survey project link as shown in
Figure 4–13.
Figure 4–14 Issues Report for Open Employee Satisfaction Survey Issues
Notice the filters in the report settings section. The Issues report has been filtered
by project and by status.
Related Documentation
For additional information on this and related topics:
■ Interactive Report Online Help
■ Oracle Database Application Express Advanced Tutorials
"Using Advanced Report Techniques"
"How to Design an Issue Tracking Application"
"How to Build and Deploy an Issue Tracking Application"
■ Oracle Database 2 Day + Application Express Developer's Guide
"Building the Application"
■ Oracle Database Application Express User's Guide
"Editing Interactive Reports"
■ Using Interactive Report Regions (OBE)
http://www.oracle.com/technology/obe/hol08/apex31nf/apexusr31/apexusr31_otn.htm
Data and form elements in an Oracle Application Express application are placed on a
page using containers called regions. There are several attributes that control the
placement and positioning of regions on pages. In turn, you control the placement and
style of form elements (called items) inside of regions using item attributes.
In this tutorial, you create the underlying data objects for a data input form by running
a script. Then, you create a data input form and learn how to change the form layout
by altering region and item attributes.
This section contains the following topics:
■ Creating a Table and Data Input Form
■ Changing the Appearance of a Page by Altering Region Attributes
■ Understanding How Item Attributes Affect Page Layout
■ Adding a Region Header and Footer
■ Making a Region Conditional
■ Adding a Region to Contain Hint Text
■ Changing Item Types
■ About Label Templates
■ Changing Buttons
■ Running the Page for Update
■ Making Data Bold
For additional examples on this and related topics, please visit the following Oracle by
Examples (OBEs):
■ Creating and Running an Application
http://www.oracle.com/technology/obe/hol08/apexintro/apex3.1.1_b/apex3.1.1_b_otn.htm
'MANUFACTURING','HR')),
emp_hiredate DATE,
emp_manager NUMBER references ht_emp,
emp_special_info VARCHAR2(2000),
emp_telecommute VARCHAR2(1) check (emp_telecommute in ('Y')),
rec_create_date DATE not null,
rec_update_date date)
/
5. Click Save.
The script appears in the SQL Scripts Repository.
6. Run the HT_EMP script:
a. Click the HT_EMP script.
b. Click Run.
c. On the Run Script page, click Run again.
7. From the View list, select Details and click Go.
3. Click Create.
4. Select Create Application and click Next.
5. For Name, specify the following:
a. Name - Enter Form Layout.
b. Application - Accept the default.
c. Create Application - Accept the default, From scratch.
d. Schema - Select the schema where you installed the OEHR sample objects.
e. Click Next.
Next, you need to add pages. You have the option of adding a blank page, a
report, a form, a tabular form, or a report and form. For this exercise, you add
two blank pages.
6. Add a blank page:
a. Under Select Page Type, accept the default, Blank.
b. Click Add Page.
The blank page appears at the top of the page.
7. Click Next.
8. For Tabs, accept the default, One Level of Tabs, and then click Next.
9. For Copy Shared Components from Another Application, accept the default, No,
and click Next.
10. For Attributes, accept the defaults for Authentication Scheme, Language, and User
Language Preference Derived From and then click Next.
11. For User Interface, select Theme 12 and then click Next.
12. For Branching, enter 2 (the page you are creating) in both fields and click Next.
Since this page is just for demonstration, you will not be utilizing branching.
13. Click Finish.
14. Click the Edit Page icon.
The Page Definition for page 2 appears.
15. Delete the following validation:
2. If prompted for a user name and password, enter your workspace user name and
password and click Login. See "About Application Authentication" on page 1-6.
The application appears.
As shown in Figure 5–3 on page 5-6, the new form appears. Note that the form
contains basic employee details and includes select lists, text areas, and display only
items.
By default, the Primary Key column does not display since it is assumed that the
primary key is system generated. In reality, the primary key is included in the page,
but appears as a hidden item.
Notice that the page defaults with one item for each row and labels display to the left
of the items. The item labels default to the column names with initial capitalization
and with the underscores (_) replaced with spaces. You can override this default
behavior by configuring user interface defaults for the table.
Also notice that items based on date columns default to include a date picker. Lastly,
notice that the Emp Special Info item was created as a text area because of the size of
the base column. This item type is a better choice for large text items since it allows the
input text to wrap.
Figure 5–4 Employee Info Form with New Display Point and Template
Note the changes in the appearance of the form. The form title displays in a dark color
on a white background and has a rule beneath it. Also, note that there is no longer a
border around the form.
Table 5–1 New Prompt, New Line, and Width Field Values
Prompt Field New Line Width
Emp ID Yes 30
First Name Yes 15
Middle Initial No 2
Last Name No 15
Part or Full Time Yes 2
Salary Yes 10
Department Yes 15
Hire Date Yes 10
Table 5–1 (Cont.) New Prompt, New Line, and Width Field Values
Prompt Field New Line Width
Manager No 15
Special Information Yes 60
Telecommute Yes 2
Record Create Date Yes 10
Record Update Date Yes 10
Figure 5–6 Employee Info Form After Editing the Prompt, New Line, Width Attributes
As shown in Figure 5–6, note that some items are pushed too far to the right
because of the width of the Special Information item. Oracle Application Express
lays out regions as tables, and the width of each column is determined by the
largest display width of the items in that column.
column as Middle Initial. Because the Manager item is larger than Middle Initial,
Last Name would still be pushed too far to the right. To fix this, you could change
the Column Span of the Manager item to 3 so it displays above Special
Information.
■ Reset the column width in the middle of the region by adding an item of type Stop
and Start HTML Table. This forces the close of an HTML table using the
</table> tag and starts a new HTML table. Inserting a Stop and Start HTML
Table item just after the Last Name item results in an even layout. Note that a Stop
and Start HTML Table item only displays its label. You can prevent the label from
displaying at all by setting it to null. To do this, you simply remove the defaulted
label.
The Drag and Drop Layout page appears. This page is divided into the Item
palette on the left and the Layout region on the right.
3. In the Item palette, select the Stop and start table icon and drop it after the row
containing the P2_EMP_ID item:
a. Move your mouse over the icons in the Item palette and locate the Stop and
start table. Note that when you position the cursor over an item type, a tooltip
appears.
b. Click the Stop and start table icon and drag it beneath of P2_EMP_ID.
c. Click Next.
A report appears. Note that the new Stop and Start HTML Table appears
beneath P2_EMP_ID.
3. Under User Interface, select Hide and Show Region from the Template list.
4. Click Apply Changes.
5. Click the Run Page icon in the upper right corner.
Figure 5–14 demonstrates how Audit Information displays as a Hide/Show
region. You can hide the region by clicking the icon to the right of the region title.
As shown in Figure 5–15 on page 5-16, the text of the footer is wrapped with the italic
HTML tag and there is an imbedded break. Without the manual break, the text would
take up the entire width of the region (as defined by region template).
7. Click the Run Page icon. Figure 5–16 shows the new Hint region on the page.
Tip: For simplicity, this tutorial has you alter items by editing item
attributes. As a best practice, however, you can also create named
LOVs and reference them.
This definition will display as two radio buttons with the labels Full-time and
Part-time, but the value being inserted into the database will be either F or P.
6. At the top of the page, click Apply Changes.
7. Click the Run Page icon in the upper right corner. The modified form appears as
shown in Figure 5–17.
Notice that Full-time and Part-time displays as a radio group that is stacked in one
column. You can have these buttons display side by side.
To display the Full-time and Part-time radio buttons side by side:
1. Go to the Page Definition for page 2.
2. Under Items, select P2_EMP_PART_OR_FULL_TIME.
3. Scroll down to List of Values.
4. In Number of Columns, enter 2.
5. At the top of the page, click Apply Changes.
6. Click the Run Page icon.
By changing this setting to match the number of valid values (that is, Full-time
and Part-time), the values display side by side as shown in Figure 5–18.
The last two selections take into account that the EMP_DEPT column can
contain nulls. As a best practice, whenever you implement a select list and
have a column that can be null, you should set Display Null to Yes. Failure to
do so results in the item defaulting to the first item in the select list.
6. At the top of the page, click Apply Changes.
7. Click the Run Page icon.
The revised form appears as shown in Figure 5–19.
This List of values definition displays the check box after the label, but will not
display a value associated with the check box. If the check box is checked, the
value passed to the database will be Y.
7. At the top of the page, click Apply Changes.
8. Click the Run Page icon.
Note that the check box appears for Telecommute as shown in Figure 5–20.
The current theme is Blue. In the Templates section, note that this theme includes
two Label templates: Optional Label with Help and Required Label with Help.
The Required with Help label template prepends a yellow asterisk to the left of the
item label. You can change the appearance of an item by selecting another
template.
To change to a different label template:
1. Go to the Page Definition for page 2.
2. Under Items, select an item.
3. Scroll down to Label and make a selection from the Template list.
4. Click Apply Changes.
5. Run the page.
Changing Buttons
The wizard that created the form in this tutorial also created buttons. These buttons
display conditionally based upon whether the page is being used to create a new
record (that is, P2_EMP_ID equals null), or the page is being used to update an
existing record. These buttons were created as HTML buttons and positioned at the
top of the region.
You can also position buttons at the bottom of the region, to the left or right of the
page title, above the region, below the region, or in any button position defined in the
region template.
To change a button position:
1. Go to the Page Definition for page 2.
2. Under Buttons, click the Edit All icon in the Buttons section. The Edit All icon
resembles a small grid with a pencil on top of it.
3. Make a new selection from the Position column.
4. Click Apply Changes.
5. Run the page.
Buttons can also have templates associated with them to refine how they look.
This will pass the value 1 to the item P2_EMP_ID. If you run the page, note that the
Delete and Apply Changes buttons now display as shown in Figure 5–22. The Create
button appeared previously because the page was expecting a new record to be
created. Also note that a value now appears in the Record Create Date field.
This example references a class in the Cascading Style Sheet associated with this
application.
5. Click Apply Changes.
6. Run the page.
In Oracle Application Express, you can create check boxes as items, or you can create
check boxes in reports. Check boxes on a form work similarly to a list of values. When
you define an item to be a check box, you need to provide the check box value in the
List of Values section of the Item Attributes page. You define check boxes on a report
using the supplied function, APEX_ITEM.CHECKBOX.
This tutorial illustrates different ways in which you can create check boxes and
explains how to reference and process the values of checked boxes. Before you begin,
you need to import and install the OEHR Sample Objects application in order to access
the necessary sample database objects. See "About Loading Sample Objects" on
page 1-2.
This section contains the following topics:
■ Creating an Application
■ Editing the Update Form
■ Change the Report Display
■ Create Multi Value Check Boxes to Filter Content
■ Adding Check Boxes to Each Row in the Report
For additional examples on this and related topics, please visit the following Oracle by
Examples (OBEs):
■ Creating and Running an Application
http://www.oracle.com/technology/obe/hol08/apexintro/apex3.1.1_b/apex3.1.1_b_otn.htm
Creating an Application
First, you need to create an application using the Create Application Wizard.
To create an application using the Create Application Wizard:
1. On the Workspace home page, click the Application Builder icon.
The Application Builder home page appears.
2. Click Create.
3. Select Create Application and click Next.
4. For Name:
a. Name - Enter Check Boxes.
b. Application - Accept the default.
c. Create Application - Select From scratch.
d. Schema - Select the schema where you installed the OEHR sample objects.
e. Click Next.
Next, you need to add a page. For this exercise, you add a report and form.
5. To add a report and form:
a. Select Page Type -Select Report and Form.
b. Table Name - Select OEHR_PRODUCT_INFORMATION.
c. Click Add Page.
Two new pages appear in the list at the top of the page. Note that each page
has the same page name. Next, edit the page names to make them more
meaningful.
6. To edit the name of page 1:
a. Click OEHR_PRODUCT_INFORMATION next to page 1 at the top of the
page as shown in Figure 6–1.
2. If prompted to enter a user name and password, enter your workspace user name
and password and click Login. See "About Application Authentication" on
page 1-6.
The application appears. Note that the report contains eleven columns displaying
product information. Users can link to an update form by clicking the Edit icon in
the far left column.
3. Click the Edit icon next to a specific product. As shown in Figure 6–3, an update
form appears.
Tip: For simplicity, this tutorial has you create a checkbox by editing
item attributes. As a best practice, however, you can also create a
named LOV and reference it.
Note that this sequence positions the item below the P2_MIN_PRICE item (the
Minimum Price field).
c. Region - Select Update Form.
d. Click Next.
6. For List of Values:
a. Named LOV - Select Select Named LOV.
b. Display Null Option - Select No.
c. List of Values Query - Enter:
STATIC:Yes;Y,No;N
d. Click Next.
7. For Item Attributes:
a. Label - Replace the existing text with Set Minimum Price.
b. Accept the remaining defaults.
c. Click Next.
8. For Source:
a. Item Source - Select SQL Query.
b. Item Source Value - Enter:
SELECT 'Y' FROM DUAL WHERE :P2_LIST_PRICE*0.75=:P2_MIN_PRICE
Create a Process
Next, you create a page process that sets the minimum price at a 25% discount of the
list price.
To create a page process:
1. On the Page Definition for page 2, locate the Page Processing area.
2. Under Processes, click the Create icon.
3. For Process Type, select PL/SQL and click Next.
4. For Process Attributes:
a. Name - Enter Update Min Price.
b. Sequence - Accept the default.
c. Point - Select OnSubmit - After Computations and Validataions.
d. Click Next.
5. For Process:
a. Enter the following:
UPDATE oehr_product_information
SET MIN_PRICE=(:P2_LIST_PRICE*0.75)
WHERE PRODUCT_ID=:P2_PRODUCT_ID;
b. Click Next.
6. For Messages:
a. Success Message - Enter:
Product successfully updated.
c. Click Next.
7. For Process Conditions:
a. Condition Type - Select Value of Item in Expression 1 = Expression 2.
b. Expression 1 - Enter:
P2_SET_MIN_PRICE
c. Expression 2 - Enter Y.
d. Click Create Process.
Figure 6–5 Update Form with Set Minimum Price Radio Group
Run the Page To run the page, click the Run Page icon in the upper right corner. The
revised form appears as shown in Figure 6–6 on page 6-7. Note the new Set Minimum
Price check box.
Figure 6–6 Update Form with Set Minimum Price Check Box
The Report Attributes page appears. You can use this page to precisely control the
report layout. First, change the number of columns that display.
4. Deselect the Show check box for the following columns:
■ Weight Class
■ Warranty Period
■ Supplier ID
Next, edit List Price and Min Price columns to include a currency symbol.
5. Edit the List Price column:
a. Click the Edit icon next to List Price.
b. From Number / Date Format, select $5,234.10.
c. Click the Next (>) icon at the top of the page.
Clicking the Next icon submits your changes and then displays attributes for
the next column, Min Price.
6. Edit the Min Price column:
a. From Number / Date Format, select $5,234.10.
Note that you select a format by selecting an example. However, the value that
actually displays field is the Oracle number format.
b. Click Apply Changes.
7. Click the Run Page icon in the upper right corner.
The revised report appears. Notice the Weight Class, Warranty Period, and
Supplier ID no longer appear and the List Price and Min Price columns include a
currency symbol.
Note: Note that to create a multi value check box, the List of Values
query must return more than one row.
b. Click Next.
5. For Condition:
a. From Condition Type, select Value of Item in Expression 1 Is NULL.
b. In Expression 1, enter:
P1_REPORT_SEARCH
6. Click Create.
The Page Definition for page 1 appears.
7. Click the Run Page icon in the upper right corner. Note that the Product Status
check boxes display at the top of the page.
Form Element Option Attributes are used exclusively for check boxes and radio
buttons and control the way the Application Express engine renders individual
options.
5. Click Apply Changes.
The Page Definition for page 1 appears.
Call APEX_ITEM.CHECKBOX
To edit the query to call APEX_ITEM.CHECKBOX:
1. Go to the Page Definition for page 1.
2. Under Regions, click Product Report.
3. Scroll down to Source.
4. In Region Source, add the new line appearing in bold face to the query.
SELECT
"product_id",
apex_item.checkbox(1,product_id) del,
"product_name",
"product_description",
"category_id",
"weight_class",
"warranty_period",
"supplier_id",
"product_status",
"list_price",
"min_price",
"catalog_url"
FROM "oehr_product_information"
WHERE instr(':'||:p1_report_search||':',product_status)> 0
APEX_ITEM is an Oracle Application Express supplied package that you can use
to generate certain items dynamically. Note that the value passed in for p_idx in
the above example is 1. You reference the check box values using the global
variable APEX_APPLICATION.G_F01 later on.
Oracle Application Express automatically adds new columns to the end of the
column list. Next, you need to move the DEL column.
5. Scroll to the top of the page and select the Report Attributes tab.
6. Under Column Attributes, locate the Del column.
7. Click the Up arrow on the far right until the DEL column is directly below
PRODUCT_ID. (See Figure 6–8 on page 6-12).
Add a Process
To add a process that executes when the user clicks the Delete Products button:
1. Under Page Processing, Processes, click the Create icon.
2. For Process Type, select PL/SQL and click Next.
3. For Process Attributes:
a. Name - Enter Delete Products.
b. Sequence - Accept the default.
c. For Point - Select On Submit - After Computations and Validations.
d. Click Next.
4. Enter the following PL/SQL process and then click Next:
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
DELETE FROM oehr_product_information
WHERE product_id = APEX_APPLICATION.G_F01(i);
END LOOP;
APEX_ITEM is an Oracle Application Express supplied package that you can use
to generate certain items dynamically. When a page is submitted, the values of
each column are stored in global package arrays, which you can reference using
the PL/SQL variable APEX_APPLICATION.G_F01 to APEX_APPLICATION.G_
F50. In this exercise, the value passed in for product_id is 1, so you reference
the column values using the global variable APEX_APPLICATION.G_F01.
5. On Messages:
a. In Success Message, enter:
Product(s) deleted.
Web services enable applications to interact with one another over the Web in a
platform-neutral, language independent environment. In a typical Web services
scenario, a business application sends a request to a service at a given URL by using
the HTTP protocol. The service receives the request, processes it, and returns a
response. You can incorporate calls to external Web services in applications developed
in Oracle Application Express.
Web services in Oracle Application Express are based on SOAP (Simple Object Access
Protocol). SOAP is a World Wide Web Consortium (W3C) standard protocol for
sending and receiving requests and responses across the Internet. SOAP messages can
be sent back and forth between a service provider and a service user in SOAP
envelopes.
Web services are called from within an Oracle Application Express application by:
■ Using the Universal Description, Discovery, and Integration (UDDI) registry
■ Manually providing the WSDL URL
This tutorial illustrates the later method.
Note: The SOAP 1.1 specification is a W3C note. (The W3C XML
Protocol Working Group has been formed to create a standard that
will supersede SOAP.)
For information about Simple Object Access Protocol (SOAP) 1.1 see:
http://www.w3.org/TR/SOAP/
c. Click Next.
3. For Page and Region Attributes:
a. Form Region Title - Change to Theater Information.
b. Accept the other defaults and click Next.
4. For Input Items:
a. For P2_ZIPCODE and P2_RADIUS, accept the default, Yes, in the Create
column.
b. For P2_ZIPCODE, change the Item Label default to ZIP Code.
c. Click Next.
5. For Web Service Results:
a. Temporary Result Set Name (Collection) - Accept the default.
b. Result Tree to Report On - Select Theater (tns:Theater).
c. Click Next.
6. For Result Parameters, select all the parameters and click Finish.
7. Click Run Page.
8. If prompted to log in, enter the user name and password for your workspace and
click Login.
A form and report resembling Figure 7–1 on page 7-4 appear. Notice that the
Theater Information Form at the top of the page contains a data entry field and a
submit button, but the Results Report does not contain any data.
9. To test the form, enter 43221 in the ZIP Code field and 5 in the Radius field. Then
click Submit.
The report at the bottom of the page should resemble Figure 7–2. The report lists
the names and addresses of movie theaters matching the entered ZIP code and
radius.
8. In the URL field on the Create/Edit Web Service page, enter the endpoint of the
MovieInformation service you located. For example:
http://www.ignyte.com/webservices/ignyte.whatsshowing.webserv
ice/moviefunctions.asmx
9. Locate the SOAP action for the GetTheatersAndMovies operation:
a. If necessary, open the WSDL again. See Step 7a.
b. In the WSDL, find the soapAction attribute of the soap:operation
element, which is a child of the operation element that has a name attribute of
GetTheatersAndMovies. You can search for the following term within the
code: soap:operation soapAction.
At the time of this release, it was this attribute:
http://www.ignyte.com/whatsshowing/GetTheatersAndMovies
10. In the Action field on the Create/Edit Web Service page, enter the SOAP action
you located. For example:
http://www.ignyte.com/whatsshowing/GetTheatersAndMovies
11. In the SOAP Envelope field on the Create/Edit Web Reference page, enter the xml
code representing the SOAP Request message. For example:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://www.ignyte.com/whatsshowing"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<tns:GetTheatersAndMovies>
<tns:zipCode>#ZIP#</tns:zipCode>
<tns:radius>#RADIUS#</tns:radius>
</tns:GetTheatersAndMovies>
</soap:Body>
</soap:Envelope>
You can use a SOAP message generating tool, such as MindReef, to construct a
valid SOAP Request for a given Web service.
12. In the Store Response in Collection field, enter MOVIE_RESULTS. This is where the
response from the Web service will be stored.
The Create/Edit Web Service page should resemble Figure 7–3.
The Web Service References page appears, showing Movie Info in the list.
■ The XPath to the interesting parts of the response under the result element is:
/GetTheatersAndMoviesResponse/GetTheatersAndMoviesResult/Theater/Movies/Mov
ie
12. Select HTML as the HTML region container and click Next.
13. In the Title field, enter Movie Information and click Next.
Note that you reviewed both the Result Node Path and Message Namespace
when testing the service.
f. Click Next.
7. In the first four Parameter Names, enter Name, Rating, RunningTime, and
ShowTimes, and click Create SQL Report.
8. To test the page:
a. Click Run Page. If prompted to log in, enter your workspace user name and
password. The Movie Information form appears, as shown in Figure 7–4.
b. In the ZIP Code and Radius fields, enter information and click Submit.
The results appear in the Search Results area.
A stacked bar chart displays the results of multiple queries stacked on top of one
another, either vertically or horizontally. Using a stacked bar chart is an effective way
to present the absolute values of data points represented by the segments of each bar,
as well as the total value represented by data points from each series stacked in a bar.
Although Application Builder includes built-in wizards for generating HTML,
Scalable Vector Graphics (SVG), and Flash charts, only SVG and Flash charts support
stacked bar charts.
This tutorial describes how to create a Flash stacked bar chart. Before you begin, you
need to import and install the OEHR Sample Objects application in order to access the
necessary sample database objects. See "About Loading Sample Objects" on page 1-2.
This section contains the following topics:
■ About the Syntax for Creating Chart Queries
■ Creating an Application
■ Creating a New Page
■ Adding Additional Series
■ Updating the Sample Data
■ Viewing the Chart
■ Editing Chart Attributes
For additional examples on this and related topics, please visit the following Oracle by
Examples (OBEs):
■ Using Some Additional New Features in Oracle Application Express 3.1
http://www.oracle.com/technology/obe/apex/apex31nf/apex31misc.htm
Where:
■ link is a URL. This URL will be called if the user clicks on the that point on the
resulting chart.
■ label is the text that displays in the bar.
■ value is the numeric column that defines the bar size.
You must have all three items in your select statement. In the next example, the link is
defined as null because there is no appropriate page to link to.
For example:
SELECT null link,
last_name label,
salary value
FROM employees
WHERE DEPARTMENT_ID = :P101_DEPARTMENT_ID
Creating an Application
First, you create an application using the Create Application Wizard.
To create an application using the Create Application Wizard:
1. On the Workspace home page, click the Application Builder icon.
The Application Builder home page appears.
2. Click Create.
3. Select Create Application and click Next.
4. For Name:
a. Name - Enter Bar Chart.
b. Application - Accept the default.
c. Create Application - Select From scratch.
d. Schema - Select the schema where you installed the OEHR sample objects.
e. Click Next.
Next, you need to add a page. You have the option of adding a blank page, a
report, a form, a tabular form, or a report and form. For this exercise, you add
a blank page.
5. Add a blank page:
a. Under Select Page Type, select Blank and click Add Page.
The new page appears in the list at the top of the page.
b. Click Next.
6. For Tabs, accept the default, One Level of Tabs, and click Next.
7. For Copy Shared Components from Another Application, accept the default, No,
and click Next.
8. For Attributes, accept the defaults for Authentication Scheme, Language, and User
Language Preference Derived From and click Next.
9. For User Interface, select Theme 2 and click Next.
10. Review your selections and click Create.
The Application home page appears.
See Also: "About the Syntax for Creating Chart Queries" on page 8-1
FROM (
SELECT TO_CHAR(o.order_date,'Mon YY') sales_month,
SUM(oi.quantity * oi.unit_price) revenue,
TO_DATE(to_char(o.order_date,'Mon YY'),'Mon YY') sales_month_order
FROM OEHR_PRODUCT_INFORMATION p,
OEHR_ORDER_ITEMS oi,
OEHR_ORDERS o,
OEHR_CATEGORIES_TAB ct
WHERE o.order_date <= (trunc(sysdate,'MON')-1)
AND o.order_date > (trunc(sysdate-365,'MON'))
AND o.order_id = oi.order_id
AND oi.product_id = p.product_id
AND p.category_id = ct.category_id
AND ct.category_name like '%hardware%'
GROUP BY TO_CHAR(o.order_date,'Mon YY')
ORDER BY sales_month_order
)
The value label (in this instance, Hardware) is displayed in the legend of
stacked charts.
Tip: You can also create a chart query interactively by clicking the
Build Query button.
c. Click Next.
8. Review your selections and click Finish.
The Success page appears.
The value label (in this instance, Software) is displayed in the legend of
stacked charts. Note that this SQL matches the previous series. The only
difference is the category in the WHERE clause.
e. For When No Data Found Message, enter:
No orders found in the past 12 months.
The value label (in this instance, Office Equipment) is displayed in the
legend of stacked charts.
e. For When No Data Found Message, enter:
No orders found in the past 12 months.
3. If prompted for a user name and password, enter your workspace user name and
password and click Login. See "About Application Authentication" on page 1-6.
Your bar chart should resemble Figure 8–1.
The chart displays the revenue for each product category by month. A legend that
defines the color associated with each product appears at the top of the page. Note
that the text in X Axis is spaced too closely together. In the next section, you edit
the chart attributes to correct this issue.
Note that the chart displays on-screen gradually using a dissolve and the X Axis
displays correctly.
Oracle Application Express applications support the ability to upload and download
files stored in the database. This tutorial illustrates how to create a form and report
with links for file upload and download, how to create and populate a table to store
additional attributes about the documents, and finally how to create the mechanism to
download the document in your custom table.
This section contains the following topics:
■ Creating an Application
■ Creating an Upload Form
■ Creating a Report with Download Links
■ Storing Additional Attributes About the Document
■ Storing the Document in a Custom Table
■ Downloading Documents from the Custom Table
■ Security Issues to Consider
For additional examples on this topic, please visit the following Oracle by Examples
(OBEs):
■ Defining and Viewing BLOB Data in Oracle Application Express 3.1
http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
Creating an Application
First, create a new application using the Create Application Wizard with the
assumption you will include an upload form on page 1.
To create an application using the Create Application Wizard:
1. On the Workspace home page, click the Application Builder icon.
The Application Builder home page appears.
2. Click Create.
3. Select Create Application and then click Next.
4. For Name, specify the following:
a. For Name, enter Download App.
3. For Region:
a. Identify the type of region to add to this page - Accept the default, HTML, and
click Next.
b. Select the type of HTML region container you wish to create - Accept the
default, HTML, and click Next.
4. For Display Attributes:
a. Title - Enter Submit File.
b. Accept the remaining defaults and click Next.
5. Accept the remaining defaults and click Create Region.
The Page Definition appears.
Create a Button
Next, you need to create a button to submit the file.
To create a button:
1. Under Buttons, click the Create icon.
2. For Button Region, select Submit File (1) 1 and click Next.
3. For Button Position, select Create a button in a region position and then click
Next.
4. On Button Attributes:
a. Button Name - Enter Submit.
b. Accept the remaining defaults.
c. Click Next.
5. For Button Template, accept the default and click Next.
6. For Display Properties, accept the defaults and click Next.
7. For Branching:
9. If prompted to enter a user name and password, enter your workspace user name
and password and click Login. See "About Application Authentication" on
page 1-6.
When you run the page, it should look similar to Figure 9–3.
The Report Attributes page appears. You can add a link to the ID column by
editing Column Attributes.
3. Under Column Attributes, click the Edit icon in the ID row.
4. Scroll down to Column Link.
#ID# parses the value contained in the column where ID is the column alias.
6. At the top of the page, click Apply Changes.
7. Run the page.
When you run the page, it should look similar to Figure 9–6.
3. Click Run.
The message Table created appears in the Results section.
4. Click the Home breadcrumb link.
The Workspace home page appears.
5. Click Next.
6. For Messages:
a. Success Message - Enter:
Subject inserted
c. Click Next.
7. For Process Conditions:
a. When Button Pressed - Select SUBMIT.
b. Accept the remaining defaults and click Create Process.
7. Click Edit Page 1 on the Developer toolbar to return to the Page Definition.
3. Click Run.
The message Table Altered appears.
4. Click the Home breadcrumb link at the top of the page.
To alter the process to insert documents into the oehr_file_subject table:
1. On the Workspace home page, click Application Builder.
2. Click Download App.
3. Click Page 1.
4. Under Processes, click the Insert file description link.
5. Scroll down to Source.
6. Under Source, replace the process with the following:
IF ( :P1_FILE_NAME is not null ) THEN
INSERT INTO oehr_file_subject(id,NAME, SUBJECT, BLOB_CONTENT, MIME_TYPE)
SELECT ID,:P1_FILE_NAME,:P1_SUBJECT,blob_content,mime_type
FROM APEX_APPLICATION_FILES
WHERE name = :P1_FILE_NAME;
DELETE from APEX_APPLICATION_FILES WHERE name = :P1_FILE_NAME;
END IF;
3. Click Run.
The message Procedure Created appears.
Next, you want to run another SQL statement.
4. Click the SQL Workshop breadcrumb link and then click SQL Commands.
The SQL Commands page appears.
5. In the top section, replace the existing SQL statement with the following:
GRANT EXECUTE ON download_my_file TO PUBLIC
/
6. Click Run.
The message Statement processed appears.
7. Click the Home breadcrumb link at the top of the page to return to the Workspace
home page.
In this URL:
– #OWNER# is the parsing schema of the current application.
– download_my_file is the new procedure you just created.
– You are passing in the value of the column ID to the parameter p_file.
5. Click Apply Changes.
The Page Definition appears.
directly from a URL that is not known in a list of allowed procedures, as shown in
Change the Download Link to Use the New Procedure, results in an error message.
To avoid this situation, there are a couple of available options. The first option is to
modify the PL/SQL function WWV_FLOW_EPG_INCLUDE_MOD_LOCAL to include the
PL/SQL download_my_file procedure and then recompile. The second, described
below, is to create a page in the application that has a before header branch to the
PL/SQL download_my_file procedure. You then create a hidden item on that page
for the document ID of the document to be downloaded.
To accomplish the second option you need to:
■ Create a page with a before header branch to the PL/SQL procedure download_
my_file
■ Change the download link to use the new page to display the file
To create a page with a before header branch to the PL/SQL procedure download_
my_file:
1. On the Application Home page, click Create Page.
2. Select Blank Page and click Next.
3. For Page Number, enter 2 and click Next.
4. For Name, enter Download File and click Next.
5. For Tabs, select No and click Next.
6. Click Finish.
The Success page appears.
7. Click Edit Page icon.
The Page Definition for page 2 appears.
8. Under Regions, click the Create icon.
9. For Region:
a. Identify the type of region to add to this page - Accept the default, HTML, and
click Next.
b. Select the type of HTML region container you wish to create - Accept the
default, HTML, and click Next.
10. For Display Attributes, specify the following:
13. For Item Type, select Hidden and then click Next.
14. For Hidden Item Type, select Hidden and Protected and then click Next.
15. For Item Name, enter P2_DOC_ID and then click Next.
16. For Source, accept all defaults and then click Create Item.
The Page Definition for Page 2 appears.
17. Under Branches, click the Create icon.
18. For the Branch Point list, select On Load: Before Header.
19. For the Branch Type, select Branch to PL/SQL Procedure and then click Next.
20. For the Identify PL/SQL procedure to call text box, enter download_my_
file(:P2_DOC_ID).
21. For Branch Conditions, accept defaults and click Create Branch.
The Page Definition for page 2 appears.
One technique you can use to protect an application is to call one of the Oracle
Application Express security APIs from within the procedure in order to ensure that
the user has already been authenticated. For example, you could include a block of
code into the procedure so that it runs first. Consider the following example:
-- Assuming your application's numeric ID is 100, set g_flow_id to
-- that value, otherwise change the value as required.
--
APEX_APPLICATION.G_FLOW_ID := 100;
Adding JavaScript to a Web application is a great way to add features that mimic those
found in client/server applications without sacrificing all of the benefits of Web
deployment. Oracle Application Express includes multiple built-in interfaces
especially designed for adding JavaScript.
Remember that JavaScript is not appropriate for data intensive validations. For
example, to verify that a name is contained within a large database table, you would
need to pull down every record to the client, creating a huge HTML document. In
general, complex operations are much better suited for server-side Oracle Application
Express validations instead of JavaScript.
This tutorial describes some usage scenarios for JavaScript and includes details about
how to implement them in your application.
This section contains the following topics:
■ Understanding How to Incorporate JavaScript Functions
■ About Referencing Items Using JavaScript
■ Calling JavaScript from a Button
■ Changing the Value of Form Elements
■ Creating a Client Side JavaScript Validation
■ Enabling and Disabling Form Elements
For additional examples on this topic, please visit the following Oracle by Examples
(OBEs):
■ Incorporating JavaScript into Your Application
http://www.oracle.com/technology/obe/hol08/apexweb20/javascript_otn.htm
// Then add the following to the "Form Element Attributes" Attribute of the
item:
onchange="displayValue('P1_FIRST_NAME');"
if (confDel== true)
doSubmit('Delete');
}
</script>
This example creates a function to confirm a delete action and then calls that function
from a button. Note that the function optionally submits the page and sets the value of
the internal variable :REQUEST to Delete, thus performing the delete using a process
that conditionally executes based on the value of request.
Note that when you create the button, you need to select Action Redirect to URL
without submitting page. Then, you specify a URL target, such as the following:
9. For Attributes, accept the defaults for Authentication Scheme, Language, and User
Language Preference Derived From and click Next.
10. For User Interface, select Theme 2 and click Next.
2. When prompted for a user name and password, enter your workspace user name
and password and click Login. See "About Application Authentication" on
page 1-6.
A standard report appears. To view the update form, click either the Create button
or Edit icon.
3. Click Application on the Developer toolbar to return to the Application home
page.
Note that HTML Header already contains a script. When the user clicks the Delete
button, this script displays the following message.
Would you like to perform this delete action?
4. In HTML Header, scroll down and place your cursor after the last </script> tag.
5. After the last </script> tag, enter the following script:
<script type="text/javascript">
function notNull(object){
if(object.value=="")
alert('This field must contain a value.');
}
</script>
lEl.disabled = false;
lEl.style.background = '#ffffff';
}else{
lEl.disabled = true;
lEl.style.background = '#cccccc';
}}
return true;}
function disFormItems(){
var lOptions = document.getElementById('P2_DEPARTMENT_ID').options
var lReturn;
for(var i=0;i<lOptions.length;i++){
if(lOptions[i].selected==true){lReturn = lOptions[i].value;}
}
var lTest = lReturn == '80';
html_disableItem('P2_COMMISSION_PCT',lTest); }
</script>
Tip: For simplicity, this tutorial has you create an item-level list of
values. As a best practice, however, consider creating a named LOV
and referencing it.
For additional examples on this topic, please visit the following Oracle by Examples
(OBEs):
■ Adding Security to your Application
http://www.oracle.com/technology/obe/hol08/apexintro/apex3.1.1_d/apex3.1.1_d_otn.htm
Creating an Application
First, you need to create an application based on employee data in a spreadsheet.
Topics in this section include:
■ Download Spreadsheet Data
■ Create an Application Based on Spreadsheet Data
■ Run the Application
b. Click Next.
6. For Data:
a. Text File - Click Browse and navigate to the acl_employees.csv file.
b. Accept the remaining defaults and click Next.
7. For Table Properties:
a. Schema - Select the appropriate schema.
b. Table Name - Enter ACL_EMPLOYEES.
c. Accept the remaining defaults and click Next.
8. For User Interface Defaults:
a. Singular Name - Enter Employee.
b. Plural Names - Enter Employees.
c. Click Next.
9. For Summary Page:
a. Summary by Column - Select DEPARTMENT_ID and click Next.
b. Aggregate by Column - Do not make a selection and click Next.
10. For Application Options, accept the defaults and click Next.
2. If prompted to enter a user name and password, enter your workspace user name
and password and click Login. See "About Application Authentication" on
page 1-6.
The report appears as shown in Figure 11–2 on page 11-4.
The ACL_EMPLOYEES application enables you to view and update employee data.
To update a specific record, click the Edit icon in the far left column. Clicking the
Analyze tab provides you with access to both a visual and tabular breakdown of
the number of employees in each department.
a. Tab Options - Select Use an existing tab set and create a new tab within the
existing tab set.
b. Tab Set - Select TS1 (Employees, Analyze).
c. Tab Set Label - Enter Administration.
d. Click Next.
6. Review the confirmation page and click Finish.
A Success page appears.
Notice the page is divided into two regions: Application Administration and
Access Control List. Also note that the default Application Mode is Full Access.
2. Under Application Mode, select Restricted access. Only users defined in the
access control list are allowed.
3. Click Set Application Mode.
b. Click Run.
7. Scroll back to the top of the page and click Apply Changes.
Note that the Edit icon and the Administration tab no longer appear.
3. Click Logout in the upper right corner.
Note that the Edit icon now appears to the left of the Employee Id column, but the
Administration tab still does not appear.
2. Click Logout in the upper right corner.
A packaged application is a fully functional application that you can view, use, and
customize. Each packaged application includes installation scripts that define the
application's supporting objects (including database objects, images, and seed data) as
well as any preinstallation validations. Packaged applications can also include a
de-installation script which can be used to remove all the application's supporting
objects.
This tutorial walks you through the OEHR Sample Objects packaged application. By
reviewing the supporting objects behind this application, you can learn how to define
them in your own applications.
Before you begin, you need to import and install the OEHR Sample Objects application.
See "About Loading Sample Objects" on page 1-2.
This section contains the following topics:
■ What Is a Packaged Application?
■ About the Supporting Object Utility
■ About Supporting Objects Installation
■ About Supporting Objects Deinstallation
■ About Supporting Objects Export
■ About Creating Upgrade Scripts
■ About Refining Your Installation Scripts
■ Downloading Public Packaged Applications and Sample Code
The top of the Supporting Objects page displays a detailed report about the
currently selected application, including the number of scripts and the amount of
required free space. After that, the page is divided into these sections:
■ Installation
■ Upgrade
■ Deinstallation
■ Messages
This section describes the Installation and Messages sections of the Supporting Objects
page. Depending upon the needs of your application, you may use all or only some of
the functionality.
In order to give context, this section describes the supporting objects in the sequence
that they would appear to a user who is performing the installation.
Topics in this section include:
■ Welcome Message
■ Prerequisites
■ License Acceptance
■ Application Substitution Strings
■ Build Options
■ Pre-Installation Validations
■ Pre-Installation Confirmation Message
■ Installation Scripts
■ Success Message
Welcome Message
The welcome message contains text that displays to users immediately after they
indicate that they want to install the supporting objects. Use this message to introduce
the application to users and to explain any information that they may need during the
rest of the installation process.
To review the welcome message text:
1. Go to Supporting Objects page as described in "Accessing the Supporting Objects
Page" on page 12-2.
2. In the Messages section, click Welcome message.
The Supporting Object Messages page appears. The Welcome message appears in
the first section.
Prerequisites
Prerequisites include anything that must be valid for the installation process to
continue.
d. Click the Detailed Tablespace Utilization Report (may take several seconds)
link.
The Detailed Tablespace Utilization Report appears.
e. Write down the number that appears in the Amount Used column.
This shows the amount of used space in the tablespace where your schema is
located.
3. Install your supporting objects by either manually creating them again, or running
your installation scripts.
a. Go to the Supporting Objects page as described in "Accessing the Supporting
Objects Page" on page 12-2.
b. From the Tasks list on the right side of the page, click Install Supporting
Objects.
c. For Install Supporting Objects, select Yes and click Next.
d. Click Install.
4. View that amount of used space again:
a. Go to the Workspace home page.
b. From the Administration list on the right, click Manage Services.
c. Under Workspace section, click Workspace Overview.
d. Click the Detailed Tablespace Utilization Report (may take several seconds)
link.
The Detailed Tablespace Utilization Report appears.
e. Write down the number that appears in the Amount Used column.
5. Subtract the initial Amount of Used number from the new number to determine
your required free space.
License Acceptance
If your application requires that users accept a specific license, specify the terms in this
area. For a required license, users are prompted to accept the terms. If they do not, the
installation does not proceed.
To review the license area:
1. On the Supporting Object Messages page, click the Messages tab.
2. Locate the section, License.
Since the OEHR Sample Objects application does not require a license, no text appears
in the License section.
Build Options
Build options are shared components that enable you to conditionally display objects.
Each build option has a status set to Include or Exclude. If an object is associated with
a disabled build option, the object does not appear to the user.
Use build options to include functionality in an application that may not be ready for
use, or should not be accessible to all installations. The code is included in the
application but not exposed to end users. Later, you can enable a build option so that
the feature becomes accessible. For each build option, you can define a custom header
message to display to the user.
Build options display in the same way as the substitution strings. You specify which
build options you want to appear to users. The users can then select them and
determine their status.
The OEHR Sample Objects application does not contain any build options.
Pre-Installation Validations
Validations ensure that the target database and target schema are capable of running
the installation scripts. Built-in validation types include Current Language, Exists, and
so on. You can also use any SQL or PL/SQL expressions. Validations can also be
conditionally executed.
Use these validations to check for anything that is not built-in under Prerequisites. For
example, you can check for a minimum database version or for the installation of
Oracle Text. Just as with other supporting objects, there is a Validations Message.
The OEHR Sample Objects application does not contain any validations.
Installation Scripts
Installation scripts are the core of a supporting object installation. Each application can
have several installation scripts.
The OEHR Sample Objects application contains nine installation scripts. These scripts
create objects and load data.
Tip: You can also create a custom installation script that loads files.
See "About Creating Scripts to Install Files" on page 12-13.
Notice that each script has a name and a sequence. It is very important to order your
installation scripts so that dependent objects are created or compiled correctly.
Tip: You can toggle between this page and a text page, where you
can also edit the script, by clicking the Edit Using Text Area button.
2. To view and edit the properties of the script, click the Script Properties tab.
Use the Script Properties page to change the script name or sequence. You can also
specify if it should be conditionally executed.
Creating a New Script from Scratch To create a new script from scratch:
1. Go to the Installation Scripts page:
a. Click the Supporting Objects breadcrumb.
b. Under Installation, click Installation scripts
2. On the Installation Scripts page, click Create.
3. Accept the default, Create from Scratch, and click Next.
The Create Script wizard appears.
4. For Script Attributes:
a. Name - Enter Test Script.
b. Sequence - Accept the default, 100.
c. Use Editor - Select this option.
Selecting Use Editor enables you to use the built-in editor to define your
script. If you do not select this, a standard text area appears instead.
d. Click Next.
The Script Editor opens, where you can type in or paste your script contents.
Uploading a File Often, you have files that you want to use as the basis of your
installation scripts.
To upload a file:
1. On the Installation Scripts page, click Create.
2. Select Create from file and click Next.
3. For Script Attributes:
a. Name - Enter Test Script.
b. Sequence - Accept the default, 100.
c. Click Next.
4. For Define Script, select the file to upload.
5. For this exercise, click Cancel.
Creating Scripts for Access Control Tables If your application includes an access control
list, you can create scripts to create the underlying access control tables.
If you had wanted to include a script you would select the appropriate scripts and
click Create Scripts. The name of the script defaults to the name of the object being
created, and the sequence is defaulted as well. You can alter these attributes after
creation.
For each file that you install, the appropriate deinstallation statement is also
written to the deinstallation script.
3. For this exercise, click Cancel.
Success Message
Upon completion of the supporting objects installation, either a success or failure
message appears. Use these messages to give the user information they may need to
continue.
For example, for a successful installation, you may want to provide instructions on
running the application, such as built-in usernames and passwords. For a failed
installation, you might want to tell users whom to contact or instruct them to deinstall
the application.
To review the success or fail messages:
1. On the Installation Scripts page, click the Messages tab.
2. Scroll down to the Post Installation section to review the messages.
To see where the export setting default appears in the export steps:
1. Go to the Supporting Objects page by clicking the Supporting Objects
breadcrumb.
2. From the Tasks list on the right, click Export Application.
In the Export Application section, notice that Export Supporting Object Definitions
is set to Yes. If this option is set to No, your export only included your application
definition.
3. To return to the Supporting Object Installation page, click Manage Supporting
Objects on the Tasks list on the right.
If your upgrade consists only of application-level changes (that is, there are no
supporting objects changes) you do not need to create upgrade scripts. You can simply
instruct users to install the new application, but not install supporting objects.
Oracle Application Express supports the ability to print a report by exporting a report
region to PDF. Defined declaratively, report printing enables users to view and print
reports that include page headings and that properly conform to specified page sizes.
When users print a report, the report data is transformed to a PDF format using an
externally defined report server.
In addition to enabling printing for report regions, you can also define output using
report queries and report layouts that are linked to an application.
This tutorial explains how to build a master detail form, define a report query and RTF
template, and then create a button to expose the new report.
This section contains the following topics:
■ About Oracle BI Publisher Licensing Requirements
■ Loading the Required Objects
■ Creating a Master Detail Form
■ Creating the Report Query
■ Creating the RTF Template
■ Creating the Report Layout
■ Linking the PDF Report to the Application
■ About Creating One PDF Containing All Orders
For additional examples on this topic, please visit the following Oracle by Examples
(OBEs):
■ Creating PDF Reports with Oracle Application Express 3.1
http://www.oracle.com/technology/obe/apex/apex31nf/apex31rpt.htm
Note that the wizard added two pages to the application, a report on the master
table and a master detail form that references both tables.
2. To edit an order and view the master detail form, click the Edit icon.
The Master Details page appears as shown in Figure 13–2.
P3_ORDER_MODE
P3_ORDER_STATUS
P3_ORDER_TOTAL
P3_SALES_REP
d. Accept remaining defaults and click Next.
4. For Source Queries, enter the following:
a. SQL Query - Enter the following code:
SELECT LINE_ITEM_ID,
QUANTITY,
ORDER_ITEM_ID,
PRODUCT_NAME,
to_char(UNIT_PRICE,'$9,999.99') unit_price
FROM MD_PDF_ORDER_ITEMS
WHERE ORDER_ID = :P3_ORDER_ID
b. Click Next.
5. For Data Source for Report Layout, select XML Data and the click Download
button.
This step downloads an XML file with the name of the report query, order_
details.xml.
6. Save the resulting file to your hard drive.
You will create an RTF template using this XML file and then upload it. First,
however, you must complete the process of creating the report query using a
generic report layout. You will then edit the report query to reference the new
report layout once it is created and uploaded.
7. Click Next.
8. For Report Layout File, browse to and select the order_details.xml file you
saved.
9. Click Next.
Notice the URL that displays. This is the URL that will be used to call this report
from within your application.
10. Click Finish.
Next, you need to create an RTF template using this XML file.
4. Click Ok.
Note that nothing appears on the page.
10. To define a header and footer, from the View menu, select Header and Footer.
For example, the header could contain the name of the report (for example, My
Order Report) and the footer could contain page numbers or the date the report
was executed. You can also customize the font family or font size.
11. Save your changes:
a. From the File menu, select Save As.
b. For Save as type, select Rich Text Format (*.rtf).
c. For File Name, enter order_details.rtf.
d. Exit Microsoft Word.
■ Create a Button
■ Run the Page
Create a Button
To create a button:
1. Go to the Page Definition for the Master Detail page:
a. Click the Application breadcrumb link.
b. Select Master Detail.
2. Under Buttons, click the Create icon.
2. When the report appears, click Cancel to return to the Md Pdf Order page.
3. Click the Edit icon to select another order.
Your Master Detail page should resemble Figure 13–6. Note the new Print PDF or
Order button.
4. If you do not have an Oracle BI Publisher license, or have not yet installed or
configured Oracle BI Publisher, you will not be able to save the report as a PDF.
To view a fully functional version of this application:
■ View the hosted version on apex.oracle.com. See "Viewing a Hosted
Version of the Application" on page 13-2.
■ View the example pages included with the demonstration application. Return
to the Application home page, run the Orders page, click Edit to edit an order,
and click Print PDF Order.
1. Create one report query that returns all the required columns. There would be no
need to include session state variables.
2. Load the resulting XML into Microsoft Word just as you did in this tutorial and
use the Table Wizard.
3. When prompted to specify Groupings, select the columns that you want to use as
your master.
The resulting display will include the grouped columns above a table that contains
your detail records. You can then add labels and customize the display. When the
report is run, each master value will display on a new page.
This tutorial describes how to plan, design and populate data objects for an example
Issue Tracking application. After completing this tutorial, you can go on to Chapter 15,
"How to Build and Deploy an Issue Tracking Application" to implement and deploy
the application user interface to the data objects designed in this chapter.
A completed sample Issue Tracker application and supporting scripts are available on
the Oracle Technology Network. Go to the following location and navigate to
Packaged Applications and then select Issue Tracker:
http://www.oracle.com/technology/products/database/application_
express/index.html
For additional examples on this topic, please visit the following Oracle by Examples
(OBEs):
■ Manipulating Database Objects
http://www.oracle.com/technology/obe/hol08/apexintro/apex3.1.
1_a/apex3.1.1_a_otn.htm
Note: For the purposes of this exercise, this application has been
simplified. User data is usually much more elaborate and is often
pulled from a corporate Human Resource system. Also, users
typically work on more than one project at a time. If the roles that are
assigned to a user need to be dynamic, you would implement roles as
a separate table with a foreign key that relates to the people table.
The DDL for the package specification and body is shown below. The package
specification is created first, followed by the package body. The package body is
created last because the body usually refers to tables that must already be specified. In
this example, however, the body has no references to the tables.
The Manage Script Results page displays a message that the script has been
submitted for execution.
11. To execute the procedures that load data into each table, enter the following:
begin
it_sample_data.create_sample_projects;
it_sample_data.create_sample_people;
it_sample_data.create_sample_issues;
end;
This tutorial describes how to create and deploy an application that tracks the
assignment, status, and progress of issues related to a project. This tutorial walks you
through all the steps necessary to create a robust issue tracking application. Before
following the steps outlined in this chapter you must have completed planning the
project, creating the underlying database objects, and loading demonstration data, as
described in Chapter 14, "How to Design an Issue Tracking Application".
A completed sample Issue Tracker application and supporting scripts are available on
the Oracle Technology Network. Go to the following location and navigate to
Packaged Applications and then select Issue Tracker:
http://www.oracle.com/technology/products/database/application_express/index.html
Each page serves a particular tracking function as described in Table 15–1, " Overview
of Each Issue Tracker Page".
Although the page has no content, notice that the Create Application Wizard has
created the following items:
■ Logo - The Issue Tracker 1.0 logo is displayed in top left corner.
■ Navigation Links - A navigation bar entry displays in the upper left of the
page. Logout enables the user to log out of the application.
■ Developer Links - The Developer toolbar appears on the page. These links
only display if you are logged in as a developer. Users who only have access
to run the application cannot see these links.
4. Click Application on the Developer toolbar to return to the Application home
page.
Notice that the Create Application Wizard also created a Login page.
Once you have created the basic application structure, the next step is to add content
to the Home page.
Note: The navigation links below each image will not work until you
create each of the corresponding top level pages. For example, when
you complete the Add Pages to Maintain Projects section, the Projects
link will display the Projects page.
12. Scroll down to Header and Footer. Enter the following for Region Header:
<p>Use this application to track issues as they arise for
projects within your organization.<p>
13. Click Apply Changes.
14. To see the image list on the Home page, click the Run Application icon on the
Application’s home page. The Home page should look like Figure 15–5, "Home
Page with Navigation Image List".
Projects Page (2 - Projects) This page is a report of all projects in the database.
Components included on this page are described as follows:
■ Project Name: The name of the project.
■ Start Date: The date the project was started.
■ Target End Date: The date the project is scheduled to be completed.
■ Actual End Date: The date the project was actually completed.
■ Search region: A filtered report can be obtained by selecting search criteria and
clicking the Go button.
■ Edit icon: To edit project information, click on the edit icon to the left of the project
name. The Project Details page is displayed showing the selected project’s
information.
■ Add Project button: A new project can be added to the database by clicking this
button. An empty Project Details page is displayed for you to enter specific project
information.
Project Details Page (3 - Project Details) This is a form that allows you to edit project
details, and add a new project to the database. When you click the Add Project button
or an edit icon on the Projects page this detail page is shown. All fields are empty and
the Audit Information is not included when adding a new project. Components
included on this page are described as follows:
■ Cancel: Returns you to the Project page without submitting any unapplied
changes.
■ Delete: Removes the project from the database after getting an OK response from
a delete confirmation message. This button is displayed when a project is being
edited and is not displayed when adding a project.
■ Apply Changes: Commits any project changes to the database. This button is
displayed when a project is being edited and is not displayed when adding a
project.
■ Create: Adds the project to the database. This button is displayed when a project is
being added and is not displayed when editing a project.
■ Project Details: This region allows you to enter project details.
■ Audit Information: When this region is expanded, the project audit information is
displayed. Audit information cannot be edited. Audit information is automatically
updated for this project when the project is created or modified. This region is
only included when a project is being edited.
7. For Tab Options, select Use an existing tab set and create a new tab within the
existing tab set.
The New Tab Label field appears.
8. For Tab Set, select Issue Tracker(Home).
9. For New Tab Label, enter Projects and click Next.
10. For Select Column(s), select PROJECT_ID, PROJECT_NAME, START_DATE,
TARGET_END_DATE, ACTUAL_END_DATE, and click Next.
Note that Project Name is unique and identifies the project. The ID was added to
simplify the foreign key and enable cascading updates.
11. For Edit Link Image, select the first option, and click Next.
a. Page - Enter 3.
b. Page Name - Enter Project Details.
c. Region Title - Enter Project Details.
d. Region Template - Select Form Region.
13. For Define Form Page under Create Breadcrumb Entry:
15. For Define the source for the primary key columns, accept the default, Existing
Trigger, and click Next.
16. For Select Column(s), select PROJECT_NAME, START_DATE, TARGET_END_
DATE, ACTUAL_END_DATE, and click Next.
17. Under Identify Process Options, accept the defaults for Insert, Update and Delete,
and click Next.
18. Review your selections and click Finish.
2. Change Text Label/Alt from Create to Add Project >, select Apply Changes.
3. Click the Run Page icon.
As shown in Figure 15–9, the newly created report displays the demo data.
Edit Fields To make the Project Name field larger and the date fields smaller:
1. Go to the Page Definition for Page 3, Project Details:
a. From the Developer toolbar, click Application.
b. Click 3 - Project Details.
2. Under Items, click the Edit All icon.
The Edit All icon resembles a small grid with a pencil on top of it.
3. Scroll to the right and locate the Width column:
a. For Project Name, enter 60.
b. For Start Date, enter 12.
c. For Target End Date, enter 12.
d. For Actual End Date, enter 12.
e. Click Apply Changes.
4. Return to the Page Definition. Click the Edit Page icon in the upper right corner.
The Edit Page icon resembles a small green piece of paper and pencil.
Add an Audit Report Region to Display Only When there is Something to Display To add an
Audit Report region at the bottom of the Project Details page:
1. On edit page for Page 3, under Regions, select Create button.
2. Select Report, and click Next.
3. Select SQL Report, and click Next.
Create a Validation The Form on a Table with Report Wizard created not null
validations for Name, Start Date, and End Date. You must manually create another
validation to ensure that the Actual End Date is the same or later then the Start Date.
To add a validation for the Actual End Date:
1. Under Page Processing, Validations, click the Create icon.
2. For Level, accept the default, Item level validation, and click Next.
3. For Item, select Project Details: 50.P3_ACTUAL_END_DATE (Actual End Date)
and click Next.
4. For Validation Method:
a. Select PL/SQL and click Next.
b. Accept the default, PL/SQL Expression and click Next.
5. For Sequence and Name:
a. Sequence - Enter 50.
b. Validation Name - Enter P3_END_AFTER_START.
c. Accept the remaining defaults and click Next.
6. For Validation:
a. Validation - Enter:
to_date(:P3_ACTUAL_END_DATE,:APP_DATE_FORMAT) >= to_date
(:P3_START_DATE,:APP_DATE_FORMAT)
c. Click Next.
7. For Conditions:
a. Condition Type - Select Value of Item in Expression 1 is NOT NULL
b. Expression 1 - Enter P3_ACTUAL_END_DATE
8. Click Create.
3. Click the Projects link under the second image. The Project page should look
similar to Figure 15–11.
4. Click the edit icon next to the Email Integration project and click the + sign next to
Audit Information to show details. The displayed Project Details page should look
like Figure 15–12.
Users Page (4 - Users) This page is a report of all users with access to the application.
Components included on this page are described as follows:
■ Person Name: The name of the user.
■ Person Email: The users email address.
■ Person Role: The role of this person. In later sections, each role is given a different
level of access to the application.
■ Username: The person’s username to access this application.
■ Assigned Project: The project assigned to this person.
■ Search region: A filtered report can be obtained by selecting search criteria and
clicking the Go button.
■ Edit icon: To edit user information, click on the edit icon to the left of the person’s
name. The user Information page is displayed showing the selected user’s
information.
■ Add User button: A new user can be provisioned for this application by clicking
this button. An empty User Information page is displayed for you to enter specific
user details.
User Information Page (5 - User Information) This is a form that allows you to edit existing
user information, and add a new user. When you click the Add user button or an edit
icon on the Users page this information page is shown. Components included on this
page are described as follows:
■ Cancel: Returns you to the Users page without submitting any unapplied changes.
■ Delete: Removes the user from the database after getting an OK response from a
delete confirmation message. This button is displayed when a user is being edited
and is not displayed when adding a user.
■ Apply Changes: Commits any user changes to the database. This button is
displayed when a user is being edited and is not displayed when adding a user.
■ Create: Adds the user to the database. This button is displayed when a user is
being added and is not displayed when editing a user.
■ User Information: This region allows you to enter user details.
■ Audit Report: When this region is expanded, the user audit information is
displayed. Audit information cannot be edited. It is automatically updated for this
user when the user is added or user information is edited.
a. Page - Enter 5.
b. Page Name and Region Title - Enter User Information.
c. Entry Name - Enter User Information.
14. For Define Form Page under Create Breadcrumb Entry:
16. For Define the source for the primary key columns, accept the default, Existing
Trigger, and click Next.
17. For Select Column(s), select PERSON_NAME, PERSON_EMAIL, PERSON_
ROLE, USERNAME, ASSIGNED_PROJECT, and click Next.
18. For Insert, Update and Delete, accept the defaults and click Next.
Run the Page To preview your page, click Run Page. As shown in Figure 15–15, notice
the newly created report displays the demo data.
To preview the page for adding or editing users, click the Edit icon in the far left
column. The User Information page is displayed as shown in Figure 15–16, "User
Information Page".
Modify Name of Create Button To change Create button to Add User> button:
1. On edit page for Page 4, under Buttons, select Create button.
2. Change Text Label/Alt from Create to Add User >, select Apply Changes.
3. Click the Run Page icon.
To reorder columns on the Users page:
4. On the running Users page, click the Action icon as shown in Figure 15–17.
Change the Query to Include Project Name from IT_PROJECTS To change the query to
include a join to the Projects table:
1. Go to the Page Definition for page 4 - Users:
Note that the outer join is necessary because the project assignment is optional.
5. Click Apply Changes.
6. For Confirm Interactive Report Region Change, click Apply Changes.
Run the Page To view your changes, click the Run Page icon in the upper right of the
page. As shown in Figure 15–18, you may need to run the application as a developer to
show and reorder some of the columns to look like the figure.
Add a List of Values for Projects To add a list of values for Projects:
1. Go to the Page Definition for page 5, User Information:
a. If you are viewing a form, click Application on the Developer toolbar.
b. On the Application home page, click 5 - User Information.
2. Under Shared Components, locate the Lists of Values section and click the Create
icon.
3. For Source, accept the default, From Scratch, and click Next.
4. For Name and Type:
a. Name - Enter PROJECTS.
b. Type - Select Dynamic.
c. Click Next.
5. In Query, replace the existing statements with the following:
SELECT project_name d, project_id r
FROM it_projects
ORDER BY d
Add a List of Values for Roles To add a list of values for Roles:
1. Under Shared Components, locate the Lists of Values section and click the Create
icon.
2. For Source, accept the default, From Scratch, and click Next.
3. For Name and Type:
a. Name - Enter ROLES.
b. Type - Select Static
c. Click Next.
4. Enter the display value and return value pairs shown in Table 15–2:
This specifies that the text associated with each radio group option is the same size
as other items on the page.
7. Scroll down to List of Values.
8. From the Named LOV list, select ROLES.
9. Click Apply Changes.
To edit display attributes for P5_ASSIGNED_PROJECT:
1. Under Items, click P5_ASSIGNED_PROJECT.
2. From the Display As list in the Name section, select Select List.
3. Scroll down to List of Values.
4. Under List of Values:
a. From the Named LOV list, select PROJECTS.
b. For Display Null, select Yes.
c. For Null display value, enter:
- None -
8. Click the Edit Page icon in the upper right corner to return to the Page Definition
for Page 5.
Add Audit Report To add an Audit Report region at the bottom of the User Information:
1. On edit page for Page 5, under Regions, select Create icon.
2. Select Report and click Next.
3. Select SQL Report and click Next.
4. For Create Region, make these changes:
■ Title - Enter Audit Report.
■ Region Template - Select Hide and Show Region.
■ Click Next.
5. For Enter SQL Query or PL/SQL function returning SQL Query, enter:
SELECT CREATED_ON, CREATED_BY,
MODIFIED_ON, MODIFIED_BY
FROM IT_PEOPLE
WHERE PERSON_ID = :P5_PERSON_ID
Create a Validation The Form on a Table with Report Wizard created not null
validations for Name, Email, Role and Username. You must manually create another
validation to ensure that Leads and Members have an assigned project while the CEO
and Managers do not. As a best practice, it is generally best to use built-in validation
types because they are faster. However, for this compound type of validation, you will
write a PL/SQL validation.
To add validations to ensure the correct people are assigned projects:
1. Under Page Processing, Validations, click the Create icon.
2. For Level, accept the default, Item level validation, and click Next.
3. For Item, select User Information: 50. P5_ASSIGNED_PROJECT (Assigned
Project) and click Next.
4. For Validation Method:
a. Select PL/SQL and click Next.
b. Accept the default, PL/SQL Expression and click Next.
5. For Sequence and Name:
c. Click Next.
7. Click Create.
Figure 15–19
3. Click the Users link to the far right. The Users page will be displayed and will look
similar to Figure 15–20, "Users Page".
4. Click the Edit icon to the left of Carla Downing. You will see the User page
displayed similar to the one in Figure 15–21.
Now test the validation process that ensures users with a Lead or Member role
have an assigned project.
5. For Assigned Project, select - None -, and click Apply Changes. The User
Information page is displayed with an error message.
Next, add a new user to the Issue Tracker Application.
6. Click the Users breadcrumb to go back to Users page.
7. Click the Add User> button. As shown in Figure 15–22, "Add User Page", an
empty User Information form is displayed.
8. Enter the new user’s Name, Email Address, Username and select a Role. Do not
assign a project unless the role is Lead or Member.
Note: The validation process will make sure a CEO or Manager does
not have a project assigned, and will ensure that a Lead or Member
does have a project assigned. To test the validation process, violate
one of these conditions and click Create. An error message will
appear.
9. Click Create. The Users page is displayed with the newly added user listed.
includes an Issues maintenance form. You then link this maintenance form in multiple
places. Ultimately, the Issues report will display Issues by the person who identified
the issue, project, assigned person, status, or priority.
Upon completion of this section, the application will have an Issues page, and Issues
Details page as shown in Figure 15–23, "Issues Page" and Figure 15–24, "Issue Details".
Issues Page (6 - Issues) This page reports issues that have been entered into the system
along with general issue information. Components included on this page are
described as follows:
■ Issue Summary: Short description of the issue.
■ Identified Date: The date the issue occurred.
■ Status: The issue status which can be open, closed or on-hold.
■ Priority: The issue priority which can be high, medium or low.
■ Target Resolution Date: The date this issue should be closed.
■ Progress: A brief description of progress made for this issue.
■ Actual Resolution Date: The date the issue was closed.
■ Identified By: The person who encountered the issue.
■ Project Name: The project this issue falls under. The project is a list of values
already specified in the system.
■ Assigned To: The person assigned to resolve this issue. The person must be a user
already entered into the system.
■ Search region: A filtered report can be obtained by selecting search criteria and
clicking the Go button.
■ Edit icon: To edit user information, click on the edit icon to the left of the person’s
name. The user Information page is displayed showing the selected user’s
information.
■ Add Issue button: A new issue can be added by clicking this button. An empty
Issue Details page appears for you to enter specific issue details.
Issue Details Page (7 - Issue Details) This form allows you to edit existing issue
information, and add a new issue. When you click the Add Issue button or an edit icon
on the Issues page this details page is shown. Components included on this page are
described as follows:
■ Cancel: Returns you to the Issues page without submitting any unapplied
changes.
■ Delete: Removes the issues from the database after getting an OK response from a
delete confirmation message. This button is displayed when an issue is being
edited and is not displayed when adding an issue.
■ Apply Changes: Commits any issue changes to the database. This button is
displayed when an issue is being edited and is not displayed when adding an
issue.
■ Create: Adds the issue to the database. This button is not displayed when an issue
is being edited and is displayed when adding an issue.
■ Issue Details: This region allows you to enter specific issue information.
■ Audit Report: When this region is expanded, the issue audit information is
displayed. Audit information cannot be edited. It is automatically updated for this
issue when the issue is added or issue details are edited.
11. For Select Column(s), press CTRL and select these columns:
■ ISSUE_ID
■ ISSUE_SUMMARY
■ IDENTIFIED_BY_PERSON_ID
■ IDENTIFIED_DATE
■ RELATED_PROJECT_ID
■ ASSIGNED_TO_PERSON_ID
■ STATUS
■ PRIORITY
■ TARGET_RESOLUTION_DATE
■ PROGRESS
■ ACTUAL_RESOLUTION_DATE
12. Click Next.
13. For Edit Link Image, select the first option and click Next.
Add Lists of Values Next, you need to add lists of values for Status, Priorities, and
People. To add a list of values for Status:
1. Go to the Page Definition for page 7, Issue Details.
2. Under Shared Components, Lists of Values, click the Create icon.
3. For Create List of Values, accept the default, From Scratch, and click Next.
4. On Create List of Values, make these changes:
■ Name - Enter STATUS.
■ For Type, select Static.
■ Click Next.
5. Enter the Display Value and Return Value pairs shown in Table 15–3:
Edit Specific Items Next, you edit individual items. To edit P7_IDENTIFIED_BY_
PERSON_ID:
1. Under Items on the Page Definition for Page 7, click P7_IDENTIFIED_BY_
PERSON_ID.
2. For Name, enter P7_IDENTIFIED_BY.
3. From the Display As list in the Name section, select Select List.
4. Under Label and for Label, enter Identified By.
5. Under List of Values, make these changes:
a. Named LOV - Select PEOPLE.
b. Display Null - Select Yes. The base column is mandatory, but you do not want
the first name in the list becoming the default value.
c. Null display value - Enter:
- Select Person -
6. Click the Next button (>) at the top of the page to go to the next item, P7_
IDENTIFIED_DATE.
The Edit Page Item page appears.
To edit P7_IDENTIFIED_DATE:
1. Scroll down to Default:
a. Default value - Enter:
to_char(sysdate,:APP_DATE_FORMAT);
5. Click the Next button (>) at the top of the page until you go to P7_ASSIGNED_
TO_PERSON_ID.
To edit P7_ASSIGNED_TO_PERSON_ID:
1. For Name, enter P7_ASSIGNED_TO.
2. From the Display As list in the Name section, select Select List.
3. For Label, enter Assigned To.
4. Scroll down to List of Values. For List of Values:
a. Named LOV - Select PEOPLE.
b. Display Null- Select Yes.
c. Null display value - Enter:
- Select -
5. Click the Next button (>) at the top of the page until you go to P7_STATUS.
To edit P7_STATUS:
1. From the Display As list in the Name section, select Radiogroup.
2. Under Label, enter the following in the Label field:
Status:
3. Under Element, enter the following in the Form Element Option Attributes field:
class="instructiontext"
3. Under Element, enter the following in the Form Element Option Attributes field:
class="instructiontext"
6. Click Next icon (>) at the top of the page until edit page for P7_RELATED_
PROJECT_ID not null is displayed.
7. For Name, enter P7_RELATED_PROJECT not null.
8. For Validation Expression 1, enter P7_RELATED_PROJECT.
9. Scroll down to Error Message.
10. For Error Message, enter:
Related Project must have some value.
12. Click Run icon for page 7. The Issue Details page is displayed and should look
similar to Figure 15–25.
Create Regions to Group Items Currently all items are grouped into one large region.
Displaying items in logical groups makes data entry easier for users. Therefore, you
next create four new regions named Buttons, Progress, Resolution, and Audit
Information. You also rename an existing region.
To create new regions to group items:
1. Click the Edit Page 7 link at the bottom of the page.
2. Under Regions, click the Create icon.
3. Select Multiple HTML and click Next.
4. For the first row:
a. For Sequence, enter 15.
b. For Title, enter Progress.
c. For Template, select Form Region.
5. For the second row:
a. For Sequence, enter 20.
b. For Title, enter Resolution.
c. For Template, select Form Region.
6. Click Create Region(s).
7. Under Regions, click the Create icon.
8. Select Report and click Next.
9. Select SQL Report and click Next.
Move Items to the Appropriate Regions Next, move each item to the appropriate region.
Note that you also need to modify some item widths.
To move items to the appropriate regions:
1. Under Items, click the Edit All icon.
The Page Items summary page appears.
2. Under Region, select Progress for the following items:
■ P7_ASSIGNED_TO
■ P7_STATUS
■ P7_PRIORITY
■ P7_TARGET_RESOLUTION_DATE
■ P7_PROGRESS
3. Under Region, select Resolution for the following items:
■ P7_ACTUAL_RESOLUTION_DATE
■ P7_RESOLUTION_SUMMARY
4. Under Width, make the following edits:
■ For P7_ISSUE_SUMMARY, enter 80.
■ For P7_ISSUE_DESCRIPTION, enter 80.
Change the Display of Issues Details, Progress and Resolution Regions To modify how these
columns display:
1. Click the Edit Page 7 link at the bottom of the page.
2. Under Items, click P7_ISSUE_SUMMARY.
3. For Display As, select Textarea.
4. Under Label, for Horizontal/Vertical Alignment, select Above.
5. Under Element, make these changes:
a. Maximum Width - Enter 200
b. Height - Enter 2.
6. Select Next icon at top of page to display P7_ISSUE_DESCRIPTION edit page
item.
7. Under Label, for Horizontal/Vertical Alignment, select Above.
8. Under Element, make these changes:
a. Maximum Width - Enter 2000.
b. Height - Enter 4.
9. Click Apply Changes.
10. Under Items, click P7_PROGRESS.
18. Click Run Page 7 icon at top of page. The Issue Details page shows the Issue
Summary, Issue Description and Progress labels above the text area as shown in
Figure 15–27.
Now, add a Stop and Start HTML Table item to each region. This will realign all
items in the region to be left justified.
19. Click the Edit Page 7 link from the developer toolbar.
22. To realign Related Project, Identified By and Identified Date make these changes
for Display and Position Name:
a. Item_Name - Enter P7_3_0.
b. Sequence - Enter 171.
c. Region - Select Issues Identification (1) 10.
d. Click Create Item.
23. Under Items, click the Create icon.
25. To realign Assigned To, Status, Priority, and Target Resolution Date make these
changes for Display and Position Name:
a. Item_Name - Enter P7_4_0.
b. Sequence - Enter 163.
c. Region - Select Progress (1) 15.
d. Click Create Item.
26. Under Items, click the Create icon.
28. To realign Actual Resolution Date make these changes for Display and Position
Name:
a. Item_Name - Enter P7_1_0.
b. Sequence - Enter 166.
c. Region - Select Resolution (1) 20.
d. Click Create Item.
29. Click Run Page 7 icon. the Issues Details page now has all the items aligned
properly as shown in
Change the Display of Audit Columns Because the Audit columns should be viewable but
not editable, you need to make them display only. In the following exercise, you create
a condition for the Audit Information region. As a result, the Audit Information region
displays when a user edits an existing issue, but does not appear when a user creates a
new issue.
To create a condition for the Audit Information region.
1. Click Edit Page 7 link at bottom of page.
2. Under Regions, click Audit Information.
3. Scroll down to Conditional Display.
4. From Condition Type, select Value of Item in Expression 1 is NOT NULL.
5. In Expression 1, enter the following:
P7_ISSUE_ID
Return the User to the Calling Page Because this Issue Details page will be called from
several places, when users finish with the display, they should return to the calling
page. To accomplish this, you create an item and change the branch on the Issue
Details page. Every time the Issue Details page is called, the item must be set with the
number of the calling page.
To create a hidden item:
1. Under Items, click the Create icon.
2. For Select Item Type, select Hidden and click Next.
3. For Hidden Item Type, select Hidden and click Next.
4. For Display Position and Name:
a. Item Name - Enter:
P7_PREV_PAGE
Add Functionality to Support Adding Multiple Issues Sequentially Next, you add functionality
that enables users to add more than one issue at a time. To accomplish this, you first
add a new button and then create a new branch.
To add a new button:
1. Under Buttons, click the Copy button icon between the Edit All and Create icons
at the top right of the Buttons section. The Copy icon looks like Figure 15–29.
e. With these values - Enter the following (be sure to include the period):
&P7_PREV_PAGE.
f. Click Next.
4. For Branch Conditions, make these changes:
a. Sequence - Enter 0.
b. When Button Pressed - Select CREATE_AGAIN (Create and Create Another).
5. Click Create Branch.
Run the Page To see the changes, click the Run Page icon. The new form appears as
shown in Figure 15–30, "Refined Issue Details".
The branch you just created is looking for a value in P7_PREV_PAGE. Since the page
was not called from another page, the value has not been set. You need to fix that next.
Modify Add Issue Button To call Issue Details page from the Add Issue button:
1. Go to the Page Definition for page 6, Issues.
2. Under Button, click the Create button.
3. For Text Label/Alt, enter Add Issue>.
4. Under Optional URL Redirect, make these changes:
a. Set These Items - Enter P7_PREV_PAGE
Change the Query and Display Next, change the query to display the actual values for
people and projects instead of the ID and then clean up the report display.
To change the SQL query:
1. Under Regions, select Issues.
2. Scroll down to Source.
3. Replace SQL with the following:
SELECT "IT_ISSUES"."ISSUE_SUMMARY" as "ISSUE_SUMMARY",
"IT_PEOPLE"."PERSON_NAME" as "IDENTIFIED_BY",
"IT_ISSUES"."IDENTIFIED_DATE" as "IDENTIFIED_DATE",
"IT_PROJECTS"."PROJECT_NAME" as "PROJECT_NAME",
decode("IT_PEOPLE_1"."PERSON_NAME",NULL,'Unassigned',
"IT_PEOPLE_1"."PERSON_NAME")
as "ASSIGNED_TO",
"IT_ISSUES"."STATUS" as "STATUS",
"IT_ISSUES"."PRIORITY" as "PRIORITY",
"IT_ISSUES"."TARGET_RESOLUTION_DATE" as "TARGET_RESOLUTION_DATE",
"IT_ISSUES"."PROGRESS" as "PROGRESS",
"IT_ISSUES"."ACTUAL_RESOLUTION_DATE" as "ACTUAL_RESOLUTION_DATE",
"IT_ISSUES"."ISSUE_ID" as "ISSUE_ID",
"IT_ISSUES"."RELATED_PROJECT_ID" as "PROJECT_ID"
FROM "IT_PEOPLE" "IT_PEOPLE_1",
"IT_PROJECTS" "IT_PROJECTS",
"IT_PEOPLE" "IT_PEOPLE",
"IT_ISSUES" "IT_ISSUES"
WHERE "IT_ISSUES"."IDENTIFIED_BY_PERSON_ID"="IT_PEOPLE"."PERSON_ID"
AND "IT_ISSUES"."ASSIGNED_TO_PERSON_ID"="IT_PEOPLE_1"."PERSON_ID"(+)
AND "IT_ISSUES"."RELATED_PROJECT_ID"="IT_PROJECTS"."PROJECT_ID"
11. Return to the top of the page and click the Next (>) icon. The Column Attributes
page for ASSIGNED_TO appears.
12. For Heading Alignment, select left.
13. Return to the top of the page and click the Next (>) icon. The Column Attributes
page for PROJECT_ID appears.
14. For Display Text As, select Hidden.
Reorder Tabs
Move the Issues tab so it is between the Projects and Users tab.
To change the tab order:
1. Click on the application home breadcrumb.
2. Click Shared Components.
3. Under Navigation, select Tabs.
4. Click Resequence display order link on the right panel under Standard Tab Tasks.
5. In the Sequence column, make these changes:
a. For Projects - Enter 15 for Sequence.
b. For Users - Enter 30 for Sequence.
c. For Issues - Enter 20 for Sequence.
6. Click Apply Changes.
3. Click the Issues link. The Issues page is displayed. The first time you run this
page, because you changed the names of some of the columns, you may not see
the Identify By, Project Name and Assigned To columns. If this is the case, you can
further customize the reports display by running the page and specifying which
columns you want to appear.
To specify which columns to display:
4. On the running Issues page, click the Action menu drop down to the right of the
Go button as shown in Figure 15–32
5. Select Select Columns. Your page should look similar to Figure 15–33.
6. Click the Move All icon (>>) between the Do Not Display list and the Display in
Report list. The three missing columns will move to the Display in Report list.
7. Click Apply at the bottom right of the Select Columns area. Your Issues page
should now look like Figure 15–34.
Next, you view the Issue Details page for one of the issues.
8. Click the Edit icon to the left of one of the issues. You will see the Issue Details
page displayed similar to the one in Figure 15–35.
menu/address_book_bx_128x128.png
10. Under Target, for Page, enter 9. This is the Issue Summary Report page that will
be created later in this section.
11. Click Create and Create Another.
13. Under Target, for Page, enter 8. This is the Assign Open Issues page that will be
created later in this section.
14. Click Create and Create Another.
16. Under Target, for Page, enter 11. This is the Target Resolution Dates page that will
be created later in this section.
17. Click Create and Create Another.
19. Under Target, for Page, enter 12. This is the Average Days to Resolve page that
will be created later in this section.
20. Click Create and Create Another.
menu/generate_bx_128x128.png
22. Under Target, for Page, enter 10. This is the Issues Resolved By Month page that
will be created later in this section.
23. Click Create.
Create the Reports Page To add the Reports Page that references the Image List:
1. Click the application home breadcrumb.
2. Click Create Page.
3. Select Blank Page and click Next.
4. For Page Number, enter 14 click Next.
5. For Name, enter Reports.
6. For Breadcrumb, select Breadcrumb.
7. For Parent Entry, select Home.
8. Click Next.
9. Under Tabs, select Yes - Use an existing tab set and create a new tab within the
existing tab set and click Next.
10. For Existing Tab Set, select Issue Tracker (Home, Projects, Issues...) and click
Next.
11. For Tab Label, enter Reports and click Next.
Run the Reports Page Run Reports page 14 by clicking the run icon at the top of the edit
page. As shown in Figure 15–40, the Reports page displays a list of images.
Note: Because not all the reports have been created at this point in
the tutorial, the report links under each image will not work. As each
report is created, these links will navigate to the appropriate report.
– ASSIGNED_TO_PERSON_ID
– STATUS
– PRIORITY
b. Click Next.
8. For Primary Key, accept the default, ISSUE_ID, and click Next.
9. For Primary Key Source, accept the default, Existing trigger, and click Next.
10. For Updatable Columns:
a. Page - Enter 8.
b. Page Name - Enter Assign Open Issues.
c. Region Title - Enter Assign Issues.
d. Region Template - Select No Template.
e. Breadcrumb - Select Breadcrumb.
f. Entry Name - Enter Assign Open Issues
g. For Parent Entry, select Reports.
h. Click Next.
12. For Tab Options, select Use an existing tab set and reuse an existing tab within
that tab set.
13. For Tab Set, select Issue Tracker (Home, Dashboard, Projects...).
Add Lists of Values Once you have created the initial tabular form, you need to add lists
of values to make it easier to select issues. Additionally, you need to restrict the query
to display only unassigned issues.
To add lists of values:
3. To sort by ISSUE_ID:
a. For all columns except ISSUE_ID, select Sort.
b. For IDENTIFIED_DATE, for Sort Sequence, select 1. By doing this, issues will
be displayed by oldest first.
4. Edit the following attributes for IDENTIFIED_BY_PERSON_ID:
a. Click the Edit icon to the left of IDENTIFIED_BY_PERSON_ID.
b. Under Column Definition, for Column Heading, enter Identified By.
c. Under Tabular Form Element, for Display As, select Display as Text (based
on LOV, does not save state).
d. Scroll down to Lists of Values.
e. For Named LOV, select PEOPLE.
f. Click the Next button (>) at the top of the page to go to IDENTIFIED_DATE.
5. Edit the following attributes for IDENTIFIED_DATE:
a. Under Column Formatting, for Number/Date Format, enter DD-MON-YYYY.
b. Click the Next button (>) at the top of the page to go to the RELATED_
PROJECT_ID column.
6. Edit the following attributes for RELATED_PROJECT_ID:
a. Under Column Definition, for Column Heading, enter Related Project.
b. Under Tabular Form Element, for Display As, select Select List (named LOV)
c. Under List of Values, for Named LOV, select PROJECTS.
d. Click the Next button (>) at the top of the page to go to the ASSIGNED_TO_
PERSON_ID column.
Delete the Unnecessary Cancel Button The wizard created an unnecessary Cancel button.
To delete the Cancel button:
1. On the Page Definition for page 8, click CANCEL in the Buttons section.
2. Click Delete.
3. Click OK to confirm your selection.
Run the Page The tabular form is now complete. To view the new form, click the Run
Page icon. The Assign Open Issues form appears as shown in Figure 15–41.
To assign an issue, make a selection from the Assigned To list and click Apply
Changes. Notice that once an issue has been assigned, the issue no longer displays.
Create the Report Page To create this report, you code the information in two SQL
statements. The first statement gathers information having a singular result and the
second statement gathers information having multiple results.
To add an Issue Summary by Project report:
1. Go to the Application home page.
2. Click Create Page.
3. Select Report and click Next.
4. Select SQL Report and click Next.
5. For Page Attributes:
a. Page - Enter 9.
b. Page Name - Enter Issue Summary by Project.
c. Breadcrumb - Select Breadcrumb.
d. Parent Entry - Select Reports link.
e. Click Next.
6. For Tab Options, select Use an existing tab set and reuse an existing tab within
that tab set.
7. For Tab Set, select Issue Tracker (Home, Dashboard, Projects...) and click Next.
8. For Use Tab, select T_REPORTS: label="Reports" and click Next.
9. For SQL Query:
a. Enter the following SQL SELECT statement:
b. Click Next.
10. For Report Attributes:
a. Region Template - Select List Region with Icon (Chart).
b. Report Template - Select default: vertical report, look 1 (include null
columns)
c. For Region Name - Enter Summary.
d. Accept the remaining defaults and click Next.
11. Review your selections and click Finish.
Now that you have the first query, you need to edit the headings and create the item
to control the related project. First, create a region to display above the report to
contain the Project parameter.
Create a Search Region To create a new region to display above the report:
1. From the Success page, click Edit Page 9.
The Page Definition for page 9, Issue Summary by Project, appears.
2. Under Regions, click the Create icon.
3. Select HTML and click Next.
4. Select HTML for region container and click Next.
5. For Display Attributes:
a. Title - Enter Issue Summary Report Parameters.
b. Region Template - Select Report Filter - Single Row.
c. Display Point - Select Page Template Body (2. items below region content).
d. For Sequence, enter 5.
e. Accept the remaining defaults and click Next.
6. Click Create Region.
3. For Select List Control Type, accept the default, Select List, and click Next.
4. For Display Position and Name:
a. Item Name - Enter P9_PROJECT.
b. Sequence - Enter 31.
c. Region - Select Issue Summary Report Parameters (1) 5.
d. Click Next.
5. For List of Values:
a. Named LOV - Select PROJECTS.
b. Null Text - Enter:
- Select -
d. Click Next.
6. For Item Attributes, accept the defaults and click Next.
7. For Default, enter -1.
8. Click Create Item.
Create a Reset Button Now, create a Reset button and Reset branch to redisplay the
default Issue Summary by Report Page.
To create a Reset button to clear the query:
1. Under Buttons, click the Create icon.
2. For Button Region, select Issue Summary Report Parameters and click Next.
3. For Button Position, select Create a button displayed among this region's items
and click Next.
4. For Button Attributes:
Create a Assignment by Status Region To create a new region to display below the report:
1. Under Regions, click the Create icon.
2. Select Report and click Next.
3. Select SQL Report for region container and click Next.
4. For Display Attributes:
a. Title - Enter Assignments by Status.
b. Region Template - Select No Template.
c. For Sequence, enter 20.
d. Accept the remaining defaults and click Next.
5. For Enter SQL Query or PL/SQL function returning a SQL Query, enter:
SELECT p.person_name,i.status,
COUNT(i.issue_id) issues
FROM it_issues i, it_people p
WHERE i.related_project_id = :P9_PROJECT
AND i.assigned_to_person_id = p.person_id
GROUP BY person_name, status
6. Click Next.
7. For Rows per Page, enter 20 and click Next.
8. For Conditional Display:
a. Condition Type - Select Value of Item in Expression 1 != Expression 2
b. Expression 1 - Enter P9_PROJECT
c. Expression 2 - Enter -1
9. Click Create Region.
Edit Headings and Report Settings for Summary Report Next, you need to edit the headings
and report setting for the report region. You also need to set the report regions to
conditionally display when the user has selected a project.
To edit the headings and report settings:
1. Under Regions, click Report next to Summary.
2. For Headings Type, select Custom.
3. Under Column Attributes:
a. Change the Heading for FIRST_IDENTIFIED to:
First Issue Identified:
Run the Page To see your newly created report, click the Run Page icon. Note that
initially no data displays since no project is selected. Select a project and click Go.
Your report should resemble Figure 15–42.
Add a Resolved by Month Identified Report Page To add this report page:
1. Go to the Application home page.
2. Click Create Page.
3. Select Chart and click Next.
4. Select FLASH Chart and click Next.
5. For Page Attributes:
a. Page Number - Enter 10.
b. Page Name - Enter Resolved by Month Identified.
c. Region Template - Select No Template.
d. Region Name - Enter Resolved by Month Identified.
e. Breadcrumb - Select Breadcrumb.
f. Entry Name - Enter Resolved by Month Identified.
g. Parent Entry - Click Reports link.
h. Click Next.
6. For Tab Options, select Use an existing tab set and reuse an existing tab within
that tab set.
7. For Tab Set, select Issue Tracker (Home, Dashboard, Projects...), and click Next.
8. For Use Tab, select T_REPORTS, and click Next.
9. For Chart Type, select 3D Column.
10. For Chart Animation, select Scale.
Note that this query has no link (that is, the l column). It extracts the month
from the identified date so that the data can be grouped by month. Lastly, it
calculates the average number of days it took for the issues to be closed that
were identified in that month.
b. For When No Data Found Message, enter:
No Closed Issues found.
c. Click Next.
20. Review your selections and click Finish.
Edit the Chart Next, modify month labels along x-axis to display at a 45 degree angle.
To edit the chart:
1. From the Success page, select Edit Page.
The Page Definition for page 10, Resolved by Month Identified, appears.
2. Under Regions, click Flash Chart, next to Resolved by Month Identified.
3. Under Display Settings, for Labels Rotation, enter 45.
4. Click Apply Changes.
Run the Page To view your newly created flash chart, click the Run Page icon. Your
flash chart should resemble Figure 15–43.
b. Click Next.
Note that:
– The target_resolution_date is the date on which the issue displays
– The issue_summary is concatenated with the person assigned
– The issue_id does not display, but is used to create a link to enable the user
to view and edit the issue
10. For Date/Display Columns:
Create a Search Region To create a new region to display above the calendar:
1. From the Success page, click Edit Page.
The Page Definition for page 11, Issue Summary by Project, appears.
2. Under Regions, click the Create icon.
3. Select HTML and click Next.
4. Select HTML for region container and click Next.
5. For Display Attributes:
a. Title - Enter Target Resolution Parameters.
b. Region Template - Select Report Filter - Single Row.
c. Display Point - Select Page Template Body (2. items below region content).
d. For Sequence, enter 5.
e. Accept the remaining defaults and click Create.
Add an Item to Support Project Look Up To enable the user to look up one project or all
projects, you need to add an item.
To add an item to support project look up:
1. Under Items, click the Create icon.
2. For Item Type, select Select List and click Next.
3. For Select List Control Type, select Select List and click Next.
4. For Display Position and Name:
a. Item Name - Enter P11_PROJECT.
b. Sequence - Enter 30.
c. Region - Select Target Resolution Parameters (1) 5.
d. Click Next.
5. For List of Values:
a. Named LOV - Select PROJECTS.
b. Display Null Option - Select Yes.
c. Null Text - Enter:
- All -
e. Click Next.
6. For Item Attributes, accept the defaults and click Next.
7. For Source, Default, enter:
-1
3. For Button Position, select Create a button displayed among this region's items
and click Next.
4. For Button Attributes:
a. Button Name - Enter P11_GO.
b. Sequence - Enter 40.
c. Show: - Select Beginning on New Field.
d. Label - Enter Go.
e. Request - Enter Go.
f. Button Style - Select Template Based Button.
g. Template - Select Button.
5. Click Create Button.
Create a Reset Button Now, create a Reset button and Reset branch to redisplay the
default Target Resolution Dates page.
To create a Reset button to clear the query:
1. Under Buttons, click the Create icon.
2. For Button Region, select Target Resolution Parameters (1) 5 and click Next.
3. For Button Position, select Create a button displayed among this region's items
and click Next.
4. For Button Attributes:
a. Button Name - Enter P11_RESET.
b. Sequence - Enter 30.
c. Show: - Select Beginning on New Field.
d. Label - Enter Reset.
e. Request - Enter Reset.
f. Button Style - Select Template Based Button.
g. Template - Select Button.
5. Click Create Button.
To create a Reset branch:
1. Under Branches, select Create icon.
2. Accept defaults and click Next.
3. For Target, make these changes:
a. Page - Enter 11.
b. Reset Pagination for this page - Select the checkbox.
c. Clear Cache - Enter 11.
d. Click Next.
4. For When Button Pressed, select *P11_RESET.
5. Click Create Branch.
Modify Calendar Buttons To move the Calendar buttons to the Search region and
modify:
1. Under Buttons, click the Edit All icon.
2. Make the following changes for each button:
■ Region - Select Target Resolution Parameters.
■ Align - Select Right.
■ Position - Select Region Template Position #CREATE#.
3. Click Apply Changes.
Modify Calendar Attributes Lastly, you need to modify the Calendar Attributes to add
link support for viewing and editing the displayed issues. To accomplish this, you
need to call page 7, Issue Details, to clear any data from the page and pass in the
current issue ID along with the fact that page 11 was the calling page. Then, you need
to add a note that displays when the query excludes Closed issues.
To modify the Calendar Attributes:
1. Click Page 11 breadcrumb.
2. Under Regions, click Calendar to the right of Target Resolution Dates
3. Scroll down to Column Link, enter the following:
a. Target is a - Select URL.
b. URL Target - Enter:
f?p=&APP_ID.:7:&SESSION.::&DEBUG.:7:P7_ISSUE_ID,P7_PREV_PAGE:#ISSUE_ID#,11
Run the Page To see your newly created calendar, click the Run Page icon. Note that
you can click Weekly or Daily to see the corresponding calendar views. You can run
the Issues page to find Target Resolution Dates. Then, run this Target Resolution Dates
page and use the <Previous, and Next> buttons to navigate to the month of the target
resolution date. You’ll see the issue appear similar to the issue shown for Sunday
January 13,2008 in Figure 15–44 on page 15-72.
Note that you can also click the text displayed for an issue to display the Edit Issue
page. To return to the calendar, click Cancel.
Note: Your data will have different dates because the insert scripts
for the data are set relative to your system date; they are not hard
coded. The dates will be different each time the script is inserted.
6. For Tab Options, select Use an existing tab set and reuse an existing tab within
that tab set.
7. For Tab Set, select Issue Tracker (Home, Dashboard, Projects...) and click Next.
8. For Use Tab, select T_REPORTS and click Next.
9. For Chart Preview:
a. Chart Type - Select Horizontal 2D Column.
b. X Axis - Enter Days.
c. Click Next.
10. For Query:
a. For SQL Query or PL/SQL function returning a SQL Query - Enter the
following:
SELECT NULL l,
NVL(p.person_name,'None Assigned') person,
AVG(i.actual_resolution_date-i.identified_date) days
FROM it_issues i, it_people p
WHERE i.assigned_to_person_id = p.person_id (+)
AND i.status = 'Closed'
GROUP BY p.person_name
Run the Page To view your newly created bar chart, click Run Page. Your report
should resemble Figure 15–45.
16. Under Current For Pages, for Tab Page, enter 18.
Edit the Overdue Issues Report Now that the region has been created, you need to edit
the headings and turn the summary into a link to display the issue details.
To edit the column headings:
1. Under Regions, click Report next to Overdue Issues.
2. For Headings Type, select Custom.
3. For ISSUE_SUMMARY, enter the following for Heading:
Summary
5. For TARGET_RESOLUTION_DATE:
Target
6. Use Up and Down arrows to far right of each column to order columns in the
following order: ISSUE_ID, ASSIGNEE, TARGET_RESOLUTION_DATE,
PROJECT_NAME, PRIORITY, ISSUE_SUMMARY.
7. For ISSUE_ID, deselect Show.
This enables the query to pass in the link, but not display it.
8. Select Sort only for ASSIGNEE, TARGET_RESOLUTION_DATE and PROJECT_
NAME. Deselect Sort for all others.
9. Select left for Heading Alignment for TARGET_RESOLUTION_DATE.
10. Select center for Heading Alignment for all columns except TARGET_
RESOLUTION_DATE.
11. For TARGET_RESOLUTION_DATE, select 1 for Sort Sequence.
Run Application
Run your application by clicking the run page icon. You should see the Dashboard
page with the Overdue Issues region added as shown in Figure 15–47.
2. For Region Source, replace the existing statements with the following:
SELECT i.issue_id,
i.priority,
i.issue_summary,
i.target_resolution_date,
r.project_name,
p.person_name identifiee
FROM it_issues i,
it_people p,
it_projects r
WHERE i.assigned_to_person_id IS NULL
AND i.status != 'Closed'
AND i.related_project_id = r.project_id
AND i.identified_by_person_id = p.person_id
6. Use Up and Down arrows to far right to reorder columns as follows: ISSUES_ID,
IDENTIFIEE, TARGET_RESOLUTION_DATE, PROJECT_NAME, PRIORITY, and
ISSUE_SUMMARY.
7. Click Apply Changes.
Run Application
Run your application by clicking the run page icon. The Dashboard appears. Scroll
down to the bottom of the page. You should see the Unassigned Issues region as
shown in Figure 15–48.
7. Scroll down to the Layout and Pagination section. From Pagination Scheme, select
- No Pagination Selected -.
8. Under Messages, enter the following in When No Data Found Message:
No Recently Opened Issues.
Run Application
Run your application and use the Issues Details page to add an Issue to the database.
After adding the new issue, click on the Dashboard tab. At the top right side of the
page you should see the Recently Opened Issues region, as shown in Figure 15–49,
displaying the newly added issue.
Run the Page To view the revised page, click the Run Page icon. In Figure 15–50, "Final
Dashboard with All Regions Added", three overdue issues where closed before going
to the Dashboard.
2. Click Create.
3. For Select the type of database object you want to create, click Trigger.
4. For Table Name, select IT_ISSUES and click Next.
5. For Define:
a. For Trigger Name, enter IT_ISSUES_AIU_EMAIL.
b. For Firing Point, select AFTER.
c. For Options, select insert, update.
d. For Trigger Body, enter the following:
IF (INSERTING AND :new.assigned_to_person_id IS NOT NULL)
OR
(UPDATING AND (:old.assigned_to_person_id IS NULL OR :new.assigned_to_
person_id != :old.assigned_to_person_id) AND :new.assigned_to_person_id IS
NOT NULL) THEN
FOR c1 IN
(SELECT person_name, person_email
FROM it_people
WHERE person_id = :new.assigned_to_person_id)
LOOP
IF c1.person_email IS NOT NULL THEN
FOR c2 IN
(SELECT project_name
FROM it_projects
WHERE project_id = :new.related_project_id)
LOOP
APEX_MAIL.SEND(
p_to => c1.person_email,
p_from => c1.person_email,
p_body =>
'You have been assigned a new issue. ' ||chr(10)||
'The details are below. ' ||chr(10)||
chr(10)||
' Project: '|| c2.project_name ||chr(10)||
' Summary: '||:new.issue_summary ||chr(10)||
' Status: '||:new.status ||chr(10)||
'Priority: '||nvl(:new.priority,'-'),
p_subj => 'New Issue Assignment');
END LOOP;
END IF;
END LOOP;
END IF;
e. Replace the p_to and p_from with your own valid 'email address'.
f. Click Next.
6. To review the code, expand the SQL arrow.
7. Click Finish.
PROCEDURE email_overdue;
END;
/
3. Click Run.
To create the package body:
1. On the Workspace home page, click SQL Workshop and then SQL Commands.
SQL Commands appears.
2. Enter the following in the field provided:
CREATE OR REPLACE PACKAGE BODY it_check_overdue_issues
AS
PROCEDURE email_overdue
IS
l_msg_body varchar2(32000) := null;
l_count number := 0;
BEGIN
FOR c1 IN
(SELECT pr.project_id,
pr.project_name,
pe.person_name,
pe.person_email
FROM it_projects pr,
it_people pe
WHERE pr.project_id = pe.assigned_project
AND pe.person_role = 'Lead')
LOOP
FOR c2 IN
(SELECT i.target_resolution_date,
i.issue_summary,
p.person_name,
i.status,
i.priority
FROM it_issues i,
it_people p
WHERE i.assigned_to_person_id = p.person_id (+)
AND i.related_project_id = c1.project_id
AND i.target_resolution_date < SYSDATE
AND i.status != 'Closed'
ORDER BY i.target_resolution_date, i.issue_summary)
LOOP
IF l_count = 0 THEN
l_msg_body :=
'As of today, the following issues '||
'are overdue:'||chr(10)||
chr(10)||
' Project: '|| c1.project_name ||chr(10)||
chr(10)||
' Target: '||c2.target_resolution_date ||chr(10)||
' Summary: '||c2.issue_summary ||chr(10)||
' Status: '||c2.status ||chr(10)||
' Priority: '||c2.priority ||chr(10)||
'Assigned to: '||c2.person_name;
ELSE
l_msg_body := l_msg_body ||chr(10)||
chr(10)||
END LOOP;
END email_overdue;
END it_check_overdue_issues;
/
jobno number;
BEGIN
DBMS_JOB.SUBMIT(
job => jobno,
what => 'BEGIN it_check_overdue_issues.email_overdue; END;',
next_date => SYSDATE,
interval => desired_interval);
COMMIT;
END;
/
For this DBMS_JOB, replace desired_interval with the appropriate interval. For
example, to have this job execute once each day, you would replace desired_
interval with the following:
'TRUNC(SYSDATE)+(25/24)'
■ Associate the authorization scheme with the items on the Projects and Users report
that navigate to the Project Details and User Information pages
■ Associate the authorization scheme with the Project Details and User Information
pages themselves so that a user cannot bypass the security by manually editing
the URL to the target page
To reference the current user, use the session variable:APP_USER. This session
variable is compared with the person's email address (which is the same as their
workspace or workspace name). Whenever coding this type of security, you should
always code in a user that can pass all security. You may find this user very useful for
development and testing. If you do not take this approach, you may not be able to
access the restricted pages unless you define yourself as the CEO or Manager.
9. Scroll down to Evaluation Point. For Validate authorization scheme, select Once
per session.
This selection is sufficient in this instance as the assigned role typically does not
change within a given session.
10. Click Create.
Next, you need to associate the authorization scheme with the appropriate objects.
8. Under Evaluation Point, for Validate authorization scheme, select Once per page
view.
This selection is necessary since each issue may have a different result.
9. Click Create.
Now you need to associate the authorization scheme with the appropriate objects on
the Issue Details page.
b. For Display Point, select Page Template Body (2. items below region
content).
c. For Sequence, enter 30.
d. Click Next.
5. For Source, enter the following in Enter HTML Text Region Source and click Next:
You are not authorized to modify the data for this issue because<br>you are not
the Project Lead nor is the issue assigned to you.
Note: Although the supporting objects do not need to exist for you
to import the application definition, be aware you cannot test the code
until they exist.
Create Users
In order for your application to be accessible, you need to create users. If you are still
using Oracle Application Express authentication, the simplest way to create users it to
access the Manage Users page.
To create a new user:
1. Go to the Workspace home page.
2. From the Administration list on the right side of the page, click Manage
Application Express Users.
3. From the Tasks list on the right side of the page, click Create End User.
4. Under User Identification, enter the required information.
5. Click Create User or Create and Create Another.
Where:
■ apex.oracle.com is the URL of the server
■ pls is the indicator to use the mod_plsql cartridge
■ otn is the data access descriptor (DAD) name
■ f?p= is a prefix used by Oracle Application Express
■ 11563 is the application being called
Instead of hard coding this ID as shown here, you could use the substitution string
APP_ALIAS.
■ 1 is the page within the application to be displayed
■ 3397731373043366363 is the session number
To run this example application, you would use the URL:
http://apex.oracle.com/pls/otn/f?p=11563:1
As you may recall, you created the Issue Tracker application using the Create
Application wizard. This wizard creates a process on the Login page (page 101) that
controls authentication. The contents of the process are:
WWV_FLOW_CUSTOM_AUTH_STD.LOGIN(
P_UNAME => :P101_USERNAME,
P_PASSWORD => :P101_PASSWORD,
P_SESSION_ID => :FLOW_SESSION,
P_FLOW_PAGE => :APP_ID||':1'
);
Note that the Page is hard coded into this process. Because of this, the page you pass
in to the URL is overwritten and does not need to be included. You can access the
application by using the following URL:
http://apex.oracle.com/pls/otn/f?p=11563
As you can see from the example used, the URL has no meaning and can be rather
long. The host name can be changed to make it more symbolic. You can also configure
Apache to rewrite your URL so that you can publish an abbreviated format and a URL
that would be more intuitive to your users. See your Apache documentation for
details.
This appendix contains DDLs (data definition language) and scripts necessary to
complete a number of tutorials in Oracle Application Express Advanced Tutorials.
Topics in this section include:
■ Creating Application Database Objects DDL
■ Creating Issues Script
--
-- IT_API package spec
--
create or replace package it_api
as
function gen_pk
return number;
end it_api;
/
--
-- IT_PROJECTS
--
-- The IT_PROJECTS DDL:
-- + creates the projects table with the necessary columns,
-- including a new column for a system generated primary key
-- + declares the new primary key
-- + implements the real primary key, project name, as a unique key
-- + populates the project id whenever a new record is created
-- + sets the auditing columns
-- + declares table and column comments
--
create table it_projects (
project_id number not null,
project_name varchar2(255) not null,
start_date date not null,
target_end_date date not null,
actual_end_date date,
created_on date not null,
created_by varchar2(255) not null,
modified_on date,
modified_by varchar2(255)
)
/
alter table it_projects
add constraint it_projects_pk
primary key (project_id)
/
alter table it_projects
add constraint it_projects_uk
unique (project_name)
/
create or replace trigger it_projects_biu
before insert or update on it_projects
for each row
begin
if inserting then
if :NEW.PROJECT_ID is null then
:NEW.PROJECT_ID := it_api.gen_pk;
end if;
:NEW.CREATED_ON := sysdate;
:NEW.CREATED_BY := nvl(v('APP_USER'),USER);
end if;
if updating then
:NEW.MODIFIED_ON := sysdate;
:NEW.MODIFIED_BY := nvl(v('APP_USER'),USER);
end if;
end;
/
comment on table it_projects is
'All projects currently underway.'
/
comment on column it_projects.project_id is
'The system generated unique identifier for the project.'
/
comment on column it_projects.project_name is
'The unique name of the project.'
/
comment on column it_projects.start_date is
'The start date of the project.'
/
comment on column it_projects.target_end_date is
'The targeted end date of the project.'
/
comment on column it_projects.actual_end_date is
'The actual end date of the project.'
/
comment on column it_projects.created_on is
'Audit Column: Date the record was created.'
/
comment on column it_projects.created_by is
'Audit Column: The user who created the record.'
/
comment on column it_projects.modified_on is
'Audit Column: Date the record was last modified.'
/
comment on column it_projects.modified_by is
'Audit Column: The user who last modified the record.'
/
--
-- IT_PEOPLE
--
-- The IT_PEOPLE DDL:
-- + creates the people table with the necessary columns,
-- including a new column for a system generated primary key
-- + declares the new primary key
-- + implements the real primary key, person name, as a unique key
-- + implements a check constraint to validate the roles that people
-- can be assigned
-- + implements a foreign key to validate that people are assigned to
-- valid projects
-- + implements a check constraint to enforce that all project leads
-- and team members are assigned to projects
-- + populates the person id whenever a new record is created
-- + sets the auditing columns
-- + declares table and column comments
--
create table it_people (
person_id number not null,
person_name varchar2(255) not null,
person_email varchar2(255) not null,
person_role varchar2(30) not null,
username varchar2(255) not null,
assigned_project number,
created_on date not null,
created_by varchar2(255) not null,
modified_on date,
modified_by varchar2(255)
)
/
alter table it_people
add constraint it_people_pk
primary key (person_id)
/
alter table it_people
add constraint it_people_name_uk
unique (person_name)
/
alter table it_people
add constraint it_people_username_uk
unique (username)
/
alter table it_people
add constraint it_people_role_cc
check (person_role in ('CEO','Manager','Lead','Member'))
/
alter table it_people
add constraint it_people_project_fk
foreign key (assigned_project)
references it_projects
/
alter table it_people
add constraint it_people_assignment_cc
check ( (person_role in ('Lead','Member') and assigned_project is not null) or
(person_role in ('CEO','Manager') and assigned_project is null) )
/
create or replace trigger it_people_biu
before insert or update on it_people
for each row
begin
if inserting then
if :NEW.PERSON_ID is null then
:NEW.PERSON_ID := it_api.gen_pk;
end if;
:NEW.CREATED_ON := sysdate;
:NEW.CREATED_BY := nvl(v('APP_USER'),USER);
end if;
if updating then
:NEW.MODIFIED_ON := sysdate;
:NEW.MODIFIED_BY := nvl(v('APP_USER'),USER);
end if;
end;
/
comment on table it_people is
'All people within the company.'
/
comment on column it_people.person_id is
'The system generated unique identifier for the person.'
/
comment on column it_people.person_name is
'The unique name of the person.'
/
comment on column it_people.person_role is
'The role the person plays within the company.'
/
comment on column it_people.username is
'The username of this person. Used to link login to person details.'
/
comment on column it_people.assigned_project is
'The project that the person is currently assigned to.'
/
comment on column it_people.created_on is
'Audit Column: Date the record was created.'
/
comment on column it_people.created_by is
'Audit Column: The user who created the record.'
/
comment on column it_people.modified_on is
'Audit Column: Date the record was last modified.'
/
comment on column it_people.modified_by is
'Audit Column: The user who last modified the record.'
/
--
-- IT_ISSUES
--
-- The IT_ISSUES DDL:
-- + creates the table with the necessary columns, including a new column
-- for a system generated primary key
-- + declares the new primary key
-- + implements a foreign key to validate that the issue is identified by a
-- valid person
-- + implements a foreign key to validate that the issue is assigned to a
-- valid person
-- + implements a foreign key to validate that the issue is associated with
-- a valid project
-- + implements a check constraint to validate the status that is assigned
-- to the issue
-- + implements a check constraint to validate the priority that is assigned
-- to the issue
end if;
:NEW.CREATED_ON := sysdate;
:NEW.CREATED_BY := nvl(v('APP_USER'),USER);
if :new.status is null
then :new.status := 'Open';
end if;
end if;
if updating then
:NEW.MODIFIED_ON := sysdate;
:NEW.MODIFIED_BY := nvl(v('APP_USER'),USER);
if :new.actual_resolution_date is not null
then :new.status := 'Closed';
end if;
end if;
end;
/
comment on table it_issues is
'All issues related to the projects being undertaken by the company.'
/
comment on column it_issues.issue_id is
'The system generated unique identifier for the issue.'
/
comment on column it_issues.issue_summary is
'A brief summary of the issue.'
/
comment on column it_issues.issue_description is
'A full description of the issue.'
/
comment on column it_issues.identified_by_person_id is
'The person who identified the issue.'
/
comment on column it_issues.identified_date is
'The date the issue was identified.'
/
comment on column it_issues.related_project_id is
'The project that the issue is related to.'
/
comment on column it_issues.assigned_to_person_id is
'The person that the issue is assigned to.'
/
comment on column it_issues.status is
'The current status of the issue.'
/
comment on column it_issues.priority is
'The priority of the issue. How important it is to get resolved.'
/
comment on column it_issues.target_resolution_date is
'The date on which the issue is planned to be resolved.'
/
comment on column it_issues.actual_resolution_date is
'The date the issue was actually resolved.'
/
comment on column it_issues.progress is
'Any progress notes on the issue resolution.'
/
comment on column it_issues.resolution_summary is
'The description of the resolution of the issue.'
/
comment on column it_issues.created_on is
'Audit Column: Date the record was created.'
/
comment on column it_issues.created_by is
'Audit Column: The user who created the record.'
/
comment on column it_issues.modified_on is
'Audit Column: Date the record was last modified.'
/
comment on column it_issues.modified_by is
'Audit Column: The user who last modified the record.'
/
--
-- IT_API package body
--
create or replace package body it_api
as
-- generates and returns unique number used for primary key values
function gen_pk
return number
is
l_pk number := 0;
begin
for c1 in (
select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') pk
from dual )
loop
l_pk := c1.pk;
exit;
end loop;
return l_pk;
end gen_pk;
end it_api;
/
4);
insert into it_people (person_id, person_name, person_email, person_role,
username, assigned_project)
values (17, 'Yvonne Zeiring', 'yvonee.zeiring@mrvl-bademail.com', 'Member',
'yzeirling', 4);
commit;
end create_sample_people;
procedure create_sample_issues
is
begin
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(1, 'Midwest call center servers have no failover due to Conn Creek plant
fire','',
6, sysdate-80,
3, 6, 'Closed', 'Medium', sysdate-73,
'Making steady progress.', sysdate-73, '');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(2, 'Timezone ambiguity in some EMEA regions is delaying bulk forwarding to mirror
sites','',
6, sysdate-100,
3, 14, 'Open', 'Low', sysdate-80,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(3, 'Some vendor proposals lack selective archiving and region-keyed retrieval
sections','',
6, sysdate-110,
3, 13, 'Closed', 'Medium', sysdate-90,
'', sysdate-95, '');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(4, 'Client software licenses expire for Bangalore call center before cutover','',
1, sysdate-70,
3, 6, 'Closed', 'High', sysdate-60,
'',sysdate-66,'Worked with HW, applied patch set.');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
actual_resolution_date, resolution_summary)
values
(10, 'Legal has asked for better definitions on healthcare categories for Canadian
provincial regs compliance','',
1, sysdate-10,
5, 11, 'Closed', 'Medium', sysdate+20,
'',sysdate-1,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(11, 'Action plan review dates conflict with effectivity of organizational
consolidations for Great Lakes region','',
1, sysdate-9,
5, 11, 'Open', 'Medium', sysdate+45,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(12, 'Survey administration consulting firm requires indemnification release
letter from HR SVP','',
1, sysdate-30,
5, 11, 'Closed', 'Low', sysdate-15,
'', sysdate-17, '');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(13, 'Facilities, Safety health-check reports must be signed off before capital
asset justification can be approved','',
4, sysdate-145,
1, 4, 'Closed', 'Medium', sysdate-100,
'',sysdate-110,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(14, 'Cooling and Power requirements exceed 90% headroom limit -- variance from
Corporate requested','',
4, sysdate-45,
1, 9, 'Closed', 'High', sysdate-30,
'',sysdate-35,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(15, 'Local regulations prevent Federal contracts compliance on section
3567.106B','',
4, sysdate-90,
1, 10, 'Closed', 'High', sysdate-82,
'',sysdate-85,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(16, 'Emergency Response plan failed county inspector''s review at buildings 2 and
5','',
4, sysdate-35,
1, null, 'Open', 'High', sysdate-5,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(17, 'Training for call center 1st and 2nd lines must be staggered across
shifts','',
5, sysdate-8,
2, 5, 'Closed', 'Medium', sysdate+10,
'',sysdate-1,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(18, 'Semi-monthly ISIS feed exceeds bandwidth of Mississauga backup site','',
5, sysdate-100,
2, 12, 'On-Hold', 'Medium', sysdate-30,
'pending info from supplier','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(19, 'Expat exception reports must be hand-reconciled until auto-post phaseout
complete','',
5, sysdate-17,
2, 12, 'Closed', 'High', sysdate+4,
'',sysdate-4,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(20, 'Multi-region batch trial run schedule and staffing plan due to directors by
end of phase review','',
5, sysdate,
2, null, 'Open', 'High', sysdate+15,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(21, 'Auditors'' signoff requires full CSB compliance report','',
5, sysdate-21,
2, 5, 'Open', 'High', sysdate-7,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(22, 'Review security architecture plan with consultant','',
1, sysdate-60,
4, 7, 'Closed', 'High', sysdate-45,
'',sysdate-40,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(23, 'Evaluate vendor load balancing proposals against capital budget','',
7, sysdate-50,
4, 7, 'Closed', 'High', sysdate-45,
'',sysdate-43,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(24, 'Some preferred domain names are unavailable in registry','',
7, sysdate-55,
4, 15, 'Closed', 'Medium', sysdate-45,
'',sysdate-50,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(25, 'Establish grid management capacity-expansion policies with ASP','',
7, sysdate-20,
4, 16, 'Open', 'Medium', sysdate-5,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(26, 'Access through proxy servers blocks some usage tracking tools','',
7, sysdate-10,
4, 15, 'Closed', 'High', sysdate-5,
'',sysdate-1,'');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(27, 'Phase I stress testing cannot use production network','',
7, sysdate-11,
4, 17, 'Open', 'High', sysdate,
'','','');
insert into it_issues
(issue_id, issue_summary, issue_description,
identified_by_person_id, identified_date,
related_project_id, assigned_to_person_id, status, priority,
target_resolution_date, progress,
actual_resolution_date, resolution_summary)
values
(28, 'DoD clients must have secure port and must be blocked from others','',
7, sysdate-20,
4, 17, 'On-Hold', 'High', sysdate,
'Waiting on Security Consultant, this may drag on.','','');
commit;
end create_sample_issues;
procedure remove_sample_data
is
begin
delete from it_issues where issue_id < 29;
delete from it_people where person_id < 18;
delete from it_projects where project_id < 6;
commit;
end remove_sample_data;
end it_sample_data;
/