Professional Documents
Culture Documents
By
Riaz Ahmed
KINDLE EDITION
*****
PUBLISHED BY:
Riaz Ahmed on KDP Amazon
This ebook is licensed for your personal enjoyment only. This eBook may not be re-sold or given
away to other people. If you would like to share this book with another person, please purchase an
additional copy for each recipient. If you’re reading this book and did not purchase it, or it was not
purchased for your use only, then please return to kdp.amazon.com and purchase your own copy.
Thank you for respecting the hard work of this author.
Table Of Contents
1. Oracle Application Express - Introduction
1.1 What is APEX?
1.2 Migrating to APEX
1.3 APEX and Excel
1.4 APEX and Access
1.5 About Oracle Application Express Architecture
1.6 Convert Legacy Applications
1.7 APEX Development Environment
1.8 What you need to develop the sample web application?
1.9 Download and Install Oracle XE database
1.10 Summary
4. Manage Customers
4.1 About Customer Management
4.2 Create Pages to Manage Customers
4.3 Modify Customers Page - Page 2
4.3.1 Modify Region Attributes
4.3.2 Modify Button Attributes
4.4 Modify Customer Details Page - Page 7
4.4.1 Modify Region - Customer Details
4.4.2 Create Region - Order for this Customer
4.4.3 Create Region - New Customer
4.4.4 Modify Items Attributes
4.4.5 Create Validation - Check Customer Credit Limit
4.4.6 Create Validation - Can't Delete Customer with Orders
4.5 Test your Work
4.6 Summary
5. Setup Products
5.1 About Products Setup
5.2 Create Pages for Products Setup
5.3 Modify Products Page - Page 3
5.3.1 Modify Page Attributes
5.3.2 Modify Region Attributes
5.3.3 Create Region - Top 5 Products
5.3.4 Modify Button Attributes
5.4 Modify Product Details Page - Page 6
5.4.1 Modify Page Attributes
5.4.2 Modify Region - Product Details
5.4.3 Create Region - Product Image
5.4.4 Create Button to Delete Image
5.4.5 Modify Items Attributes
5.4.6 Create Item - Image
5.4.7 Create Process - Delete Image
5.5 Test your Work
5.6 Summary
6. Place Orders
6.1 About Order Pages
6.2 Create Orders and Order Detail Pages
6.3 Modify Orders Page - Page 4
6.3.1 Delete the default Region - Orders
6.3.2 Create Region - Orders
6.3.3 Modify the Default Primary Interactive Report
6.3.4 Create Alternative Report
6.3.4(a) Report View
6.3.4(b) Chart View
6.3.4(c) Group By View
6.3.5 Create Public Report
6.3.5(a) Report View
6.3.5(b) Chart View
6.3.5(c) Group By View
6.3.6 Modify Button - Create
6.3.7 Delete Computation - P29_ORDER_ID
6.3.8 Create a Branch
6.4 Modify Order Details Page - Page 29
6.4.1 Modify Page Attributes
6.4.2 Modify Region Attributes
6.4.3 Modify Button
6.4.4 Create/Modify Items
6.4.5 Create Process - Add Rows
6.5 Test your Work
6.6 Create Page Identify Customer - Page 11
6.6.1 Modify Page Attributes
6.6.2 Create Region - Identify Customer
6.6.3 Create Region - Order Progress
6.6.4 Create Button - Cancel
6.6.5 Create Button - Next
6.6.6 Create Items
6.6.7 Create Process under Page Rendering
6.6.8 Create Dynamic Actions
6.6.9 Create Validation - Customer ID Not Null
6.6.10 Create Branches
6.7 Test your Work
6.8 The Create Customer Page - Page 18
6.8.1 Modify Page Attributes
6.8.2 Modify Region Attributes
6.8.3 Delete Region
6.8.4 Create Region - Order Progress
6.8.5 Modify Button - Cancel
6.8.6 Delete Processes and Button
6.8.7 Create New Buttons
6.8.8 Modify Process - reset page
6.8.9 Modify Branch
6.9 Test your Work
6.10 Create Page Select Items - Page 12
6.10.1 Modify Page Attributes
6.10.2 Create Region - Select Items
6.10.3 Create Region - Order Progress
6.10.4 Create Buttons
6.10.5 Create Items
6.10.6 Create Computation
6.10.7 Create Processes
6.10.7(a)Add Product to the Order Collection
6.10.7(b)Remove Product from the Order Collection
6.10.8 Create Process - Place Order
6.10.9 Create Branches
6.11 Test your Work
6.12 Create Product Info Page - Page 20
6.12.1 Modify Page Attributes
6.12.2 Create Region - Product Image
6.12.3 Create Region - Product Information
6.12.4 Create Button - Close
6.12.5 Create Item
6.13 Test your Work
6.14 Create Order Summary Page - Page 14
6.14.1 Modify Page Attributes
6.14.2 Create Region - Order Summary
6.14.3 Create Region - Order Header
6.14.4 Create Region - Order Lines
6.14.5 Create Region - Order Progress
6.14.6 Create Buttons
6.14.7 Create Item
6.15 Complete Testing
6.16 Summary
8. Advanced Reporting
8.1 About Advanced Reporting
8.2 Install BI Publisher
8.3 Configure APEX to use BI Publisher as a Print Server
8.4 Enable Network Services in Oracle Database
8.5 Test the Print Server
8.6 Install BI Publisher Desktop
8.7 Create Monthly Order Review Report
8.7.1 Create the Report Query
8.7.2 Create Report Template in MS Word
8.7.3 Format Report
8.7.4 Conditional Formatting
8.7.5 Summary Calculation
8.7.6 Add a Summary Chart
8.7.7 Add a Pivot Table
8.8 Upload Report Template to APEX
8.9 Run the Report
8.10 Create a Commercial Invoice
8.10.1 Create Query for the Invoice
8.10.2 Create Invoice Template in MS Word
8.10.3 Upload the Template to APEX
8.10.4 Call the Report from a Page
8.10.5 Test Your Work
8.11 Summary
9. Users Management
9.1 About Users Management
9.1.1 Custom_Auth Function
9.1.2 Custom_Hash Function
9.2 The Manager Users Page - Page 8
9.2.1 Modify Page Attributes
9.2.2 Modify Region Attributes
9.2.3 Modify Button Attributes
9.2.4 Create Validation - User Name Not Null
9.2.5 Create Validation - Products Not Null
9.2.6 Create Process - ApplyMRU
9.2.7 Create Process - Add Row
9.3 The Reset Password Page - Page 9
9.3.1 Modify Page Attributes
9.3.2 Modify Region Attributes
9.3.3 Create Region - Error!
9.3.4 Modify Button Attributes
9.3.5 Modify Items Attributes
9.3.6 Create Item
9.3.7 Create Validation - Passwords Must Match
9.3.8 Delete Processes
9.3.9 Create Process - Update Password
9.3.10 Modify Branch
9.3.11 Create Branch
9.4 Test your Work
9.5 Hide the Administration Tab
9.6 Application Feedback
9.7 Summary
PREFACE
Welcome aboard!
In this fast paced technological age, where things change rapidly, no one
has the time to go through lengthy concept books just to assess what the
technology has for them. As an IT professional, I too prefer concise
practical books that do not take long to understand the features offered
by the new technology.
As a strong supporter of practical stuff, I have endeavored to write this
book on Oracle Application Express. In this book, I am sharing my
personal APEX learning experience that I got by developing a clone of
the sample application provided with Oracle Application Express. This
book will walk you through to create a professional looking web-based
database application. A great starting point for novice and equally
beneficial for intermediate users, this book will allow users to
practically explore Oracle Application Express (APEX) themselves.
Besides creation of individual application pages, this book will
demonstrate many professional techniques, summarized at the end of
each chapter, to apply them to your own projects.
Leaving out the boring bits, this book will emphasize on the inspiring
and realistic example from the first chapter and will provide guidance in
the following areas to make it a one-stop solution:
1. APEX introduction
2. Create APEX development environment
3. Create a professional looking web-based database application
in APEX
4. Advanced Reporting
5. Application deployment
6. Access the application, remotely and in LAN
If you really want to know what APEX is, try the practical stuff
provided in this book and become an APEX fan. I hope this to be the
best practical book on Oracle Application Express.
Having gone through the above stuff, it is clear that you need a tool that has the capability to cope
with these shortfalls. The following list shows how APEX allows you to handle most of these issues:
The above glimpses have disclosed that APEX is capable of far more than just being an Excel or
Access replacement. Give it a try by replacing your existing desktop applications with APEX
application, and enjoy the benefits that this robust technology offers.
Initially, you are required to migrate schema definition and data using the SQL Developer Migration
Workbench and then utilize the new Application Migration Workshop to migrate Access forms and
reports. The last step is refining your new application taking advantage of all the power and
capabilities of Oracle APEX. Please note that Access forms and reports contain business logic that
cannot be generated using the migration wizard. The solution performs the bulk of the migration work
by recovering the design from existing Access application and generating APEX application based on
the findings. Follow the link http://www.oracle.com/technetwork/developer-tools/apex/application-
express/tutorial-090294.html and go through the Access Migration Tutorial.
Figure 1-1
With Oracle Database 11.1 and later, Oracle HTTP Server is replaced by embedded PL/SQL
gateway (EPG). The embedded PL/SQL gateway runs in the XML DB HTTP server in the Oracl
database and includes the core features of mod_plsql, but does not require the Oracle HTTP Server
powered by Apache. See the Figure 1-2 that illustrate Oracle Application Express architecture using
the Embedded PL/SQL Gateway.
Figure 1-2
During the installation you are required to enter and confirm SYSTEM user password. Provide
a password that you can easily remember since you’ll need it in chapter 2. I set it to manager.
The Summary page provides the APEX port, 8080, as shown in Figure 1-3. Your Installation
might have configured a different port. This port is used in the URL to connect to the APEX
environment.
1.10 Summary
This chapter introduced you to some of the important basic concepts of Oracle Application Express.
You were also guided to download and install the latest version of Oracle XE database which
contains APEX 4. In the coming chapters, our main focus will be on the practical aspect of this robust
technology. Once you get familiar with Oracle Application Express, you can explore other areas on
your own to become a master. The rest of the book will guide you to build a professional looking web
based database application, which will provide you the techniques to build your own applications.
Sales Quota demonstrates the use of a Flash Dial chart. This chart displays a value based on an
underlying SQL statement to measure sales against the defined quota for the logged in user.
Note: The Flash Dial Chart is not displayed if you log in as an Admin user.
Top Customers is a report based on a SQL query and displays a subset of the information that
appears on the Customers page. Users can link to additional details by clicking the customer name or
by clicking the View Customer icon (a right arrow, marked as K in the above figure) in the upper
right corner of the region.
Top Products is also a report based on a SQL query. This report displays a subset of the information
that displays on the Products page. Users can link to product details by clicking the product name or
by clicking the View Products icon in the upper right corner of the region.
Orders by Date displays orders by date and order amount. Users can view the Orders page by
clicking the right arrow in the upper right corner.
Sample Application is a simple HTML region that displays static Welcome text. You can create this
type of region to display explanatory information to users.
Tasks contains a list with links to other pages within the application. Links available on the Home
page Tasks list include:
- Enter a New Order links to a wizard for creating a new order.
- Add a New Customer links to a form for entering new customer information.
- Add a New Product links to a form for adding new products.
Products displays product information. This region is based on a SQL query that uses a custom
function for displaying images stored in the database.
The page has three view options; Icon, Report, and Detail. By default, the page is displayed inIcon
view. To edit product information in Icon view, click an image.
To view the information in a report format, click the View Report icon. In Report view, you can sort
by product category by clicking the column heading and then selecting the Up or Down arrow to sort
in ascending or descending mode. Users can change the appearance of the report using the Actions
menu. To edit a product description, click the Edit icon. To add a new product, click the Create
Product button at the top of the page.
Top 5 Products is also a SQL report. This report outlines the top five products based on quantities
sold.
Figure 2-6
1. Click Start > All Programs > Oracle Database 11g Express Edition > Get Started. The
following screen will appear in your browser:
2. Click the Application Express button
3. Enter System in the username and manager in the password.
4. Fill the next screen as show in Figure 2-8 and click the Create Workspace button. I used asa in
small letters for the password. This user will be the administrator of our application.
5. Successfully created workspace ASA, message appears. Click the ‘click here’ link to login.
Figure 2-10
11. Enter APEX Sample Application in the Name box and match other parameters with those as
shown in Figure 2-15. Click Next.
12. Click Blank under Select Page Type and then click the Add Page button. Your screen should
look like Figure 2-16.
In this exercise, we created a workspace and built a blank structure for our application with two
default pages. We will work in detail on individual pages from chapter 3.
In the next section we will go through another block, the underlying database objects, that already
exist for our sample application.
1. On the Workspace home page, click SQL Workshop and then Object
Browser. Object Browser appears.
2. Select an object type from the Object list in the upper left corner of the page. For example,
to view tables, select Tables.
3. To search for an object name, enter keywords in the search field beneath the Object list.
4. To perform a specific task related to the selected object, select the appropriate task button.
5. To view additional object details, select a tab beneath the object name. For example, to
view the data in the DEMO_CUSTOMERS table:
Figure 2-18
Let’s Start!
If you are logged off, login to the application using http://localhost:8080/apex. Enter the following
credentials:
a. Workspace: asa
b. Username: asa
c. Password: asa
2.5.1 Tabs
In this exercise we are going to create our application tabs. Tabs are an effective way to navigate
between pages of an application. Application Builder includes two types of tabs: standard tabs and
parent tabs. An application having only one level of tabs uses a standard tab set. A standard tab set is
associated with a specific page. You can use standard tabs to link users to other pages within your
application. A parent tab set functions as a container to hold a group of standard tabs. Parent tabs give
users another level of navigation and context (or sense of place) within the application.
3. Click Add beside Page 1 to create a new tab using tab wizard
4. Enter Customers in Tab Label, click Next
5. Enter 2 for Tab Current for Page, click Next
6. Enter 2 in Sequence box, click Next
7. Accept the default condition type ‘No Display Condition’ and click Next
8. Click Create Tab button
The Customers tab is created. Create four more tabs Products, Orders, Reports, and
Administration and set the attributes as shown in the following table. After creating all the tabs, edit
tab Page 1 and set appropriate attribute values using the table’s Home column. Edit each tab and set
values for Tab Also Current for Pages. Click Apply Changes button after modifying each tab
values. Tab Also Current for Pages means that the tab will be active for the listed page. Once
finished, your tabs should look like Figure 2-20
Figure 2-20
2.5.2 Lists
After creating tabs, our next task is to create lists. A list is a collection of links that is rendered using
a template. For each list entry, you specify display text, a target URL, and other attributes that control
when and how the list entry displays. You control the display of the list and the appearance of all list
entries by linking the list to a template.
2.5.2 (a) Tasks List
In this exercise we are going to create a list named Tasks that appear on the Home page of our
application see Figure 2-1. This list is used to create new Orders, Customers, and Products.
Figure 2-21
7. Edit Enter New Order list item and set following attributes
- Clear Cache: 11
- Remove 11 from List Entry Current for Condition
Repeat the same process for other two entries by entering 7 and 6 in Clear Cache box respectively
and removing values from the List Entry Current for Condition box.
2.5.2 (b) Report Tabs List
This list appears on the right side of the all pages under the Reports tab to display graphical reports.
See Figure 2-5.
4. Click Next button, accept the default values in the next screen and click the Create button
The wizard allowed you to create five entries. We will create Product Order Tree entry here:
That’s it. Your Reports Tab list should look like figure 2-22
Figure 2-22
4. Click the Next button, accept the default values in the next screen and click Create button
5. Click the newly created list Order Wizard
6. Edit each list item, set Target Type attribute to No Target, and set the following attributes:
List Entry Current for Condition represents corresponding page number for each step during
order creation.
7. Edit Create Customer list item and set the following attributes:
Condition Type: SQL Expression
Expression 1: NVL(:P11_CUSTOMER_OPTIONS,'EXISTING') = 'NEW'
Figure 2-23
2.5.3 Breadcrumbs
Breadcrumbs provide hierarchical navigation to any number of levels. Breadcrumb entries are
associated with pages and also identify a parent page. Here we will modify the default breadcrumb
entry. Rest of the breadcrumb entries will be defined while creating individual application pages.
1. Go to Shared Components
2. Click Globalization Attributes under Globalization section
3. Click Definition tab
4. In the Properties section set Allow Feedback to Yes
5. Click Apply Changes button
6. Go to Shared Components, Navigation Section – Navigation Bar Entries and click theCreate
button
7. Select From Scratch
8. Click Feedback
9. Select 101.Login for Feedback Page
10. Click Create button
We have not yet created the feedback page in our application which will have the ID 102. But to
complete this exercise we have to make some minor changes in the automatically created javascript to
reflect the actual feedback page number.
1. Go to Shared Components
2. Click Authentication Schemes under Security section
3. Click Application Express scheme
4. Change the Name to Custom Scheme and Description to This is a custom authentication
scheme.
5. In Authentication Function replace –BUILTIN- with return custom_auth function
6. Click Apply Changes button
The currently applied authentication scheme contains a check mark on its icon. Please make
sure that the CUSTOM SCHEME we created in this exercise has that check. If not, click the
Change Current tab on the same page. Select the scheme from the drop down list and click the
Make Current button.
1. Go to Shared Components
2. Click Authorization Schemes under Security section
3. Click Create button
4. Select From Scratch and click Next
5. Enter Admin Users in the Name box
6. Select Exists SQL Query for Scheme Type
7. In Expression 1 type select 1 from demo_users where user_name = :APP_USER and
admin_user = 'Y'
8. In Identify error message type You need to be an Admin User in order to view this page.
9. Select once per page view under Evaluation Point
10. Click Create button
declare
l_count number;
begin
select count(*) into l_count from demo_orders
where order_id = :P29_ORDER_ID and user_id =
(select user_id from demo_users where user_name = :APP_USER);
if l_count > 0 or :APP_USER = 'ADMIN' then
return true;
else
:P29_ORDER_ID := 1;
return false;
end if;
end;
You are not authorized to view this order!<br /> Click <a href="f?
p=&APP_ID.:4:&SESSION.">here</a> to continue
Note: Whenever you create an authorization scheme a reciprocal opposite {NOT} scheme is
created by APEX. For example, we created Admin Users scheme above, APEX created a
reciprocal scheme{Not Admin Users}. In Chapter 3 Section 3.2.2, we will apply both
authorization schemes Admin Users and {Not Admin Users} to the Home page regions Sales
Quota A and B.
2.5.9 Shortcuts
Use Shortcuts to write frequently used code once and then reference it in many places within your
application. In this section we will create a shortcut to display a confirmation message whenever the
Delete button is clicked on any page of the application. The following figure illustrates how it works.
When you click the Delete button, the APEX javascript function, that is created automatically with the
page having the Delete button, sends a DELETE request along with a variable,
htmldb_delete_message, initialized in the page’s Global Variable Declaration section. This variable
contains a reference to a shortcut named DELETE_CONFIRM_MSG, that holds a message, Would
you like to perform this delete action?
2.5.10 Images
Application Express images are divided into two categories:
2.6 Summary
In this chapter we created all the components required by our application. After going through the
application introduction we:
- Created a Workspace
- Created a blank application
- Saw underlying database objects
- Created all shared components
From the next chapter we are going to create all the pages of our web application, starting with the
Home page.
A/B. Sales Quota: Sales measured against quota for the logged in user. Region B will be visible for
Admin users.
C. Top Customers: List of top seven customers with most orders. When you click a customer in this
list, you are taken to the Customer Details page showing customer profile and details of all orders
placed by that customer. You can also see a tiny right arrow, [H], to the right of this region that
invokes Customers’ main page.
D. Top Products: Similar to Top Customers, this region displays top selling products with all the
drill down functionality described in the previous section.
E. Top Orders by Date: This list shows top orders on any particular day.
F. Sample Application: It is a simple HTML region that displays static Welcome text. You can create
this type of region to display explanatory information to users.
G. Tasks: This region contains a list with links to other pages within the application. Links available
on the Home page include:
- Enter a New Order links to a wizard for creating a new order.
- Add a New Customer links to a page for entering new customer information.
- Add a New Product links to a form for adding new products.
Please see section 2.2.1 Chapter 2 for more information on the Home page.
Let’s start!
4. Click on Page 1 having home icon. This will bring up the definition page as show in figure
3-2. Click Component View button, if the view of your page is different from that in figure 3-2.
For clarity purpose, only those sections of the page are shown in figure 3-2 that have some
values. Blank sections have been truncated from the screen shot.
3.2.1 Modify Page Attributes
1. In Page Rendering, click the Edit icon in Page section (see Figure 3-2). Click Show All tab
and set the following attributes. After setting these attributes, click Apply Changes button.
Let’s create our first region, Sales Quota. This region will be displayed for users other than Admin
to graphically measure their sales against the allotted quota.
1. In the Regions section, delete the two existing regions Page 1 and Breadcrumbs. Click each
region and click the Delete button and confirm deletion.
2. Click Create icon in the Regions section to create a new Region.
3. Click Chart
4. Click Flash Chart
5. Click Guages
6. Click Dial
7. Enter Sales Quota in Title, 10 in Sequence and click the Next button
8. Click Next to accept the default settings
9. Enter the following SQL Query
Create another Sales Quota region with sequence number 11. This region will be displayed for
Admin users.
Create region, Top Customers, to show top 7 customers with highest orders.
7. Edit the newly created region, Top Customers, set the following attribute:
8. Click on the Report Attributes tab on the same page and set the following attributes:
9. In Column Attribute section, edit column Customer_Name by clicking the pencil icon to
its left
10. Scroll down to Column Link section, set the following attributes and click the apply
changes button twice.
Note: You can input the above values using the keyboard or use the adjacent icons and
to select values from the popup list. The above link will work when we create Page 7 in
Chapter 4.
Create region Top Products with sequence number 30 to show 7 top selling products.
1. Click Create icon in the Regions section
2. Click Reports
3. Click SQL Report
4. Enter Top Products in Title, 30 in Sequence and click Next
5. In the next screen, enter the following SQL Query:
Select p.product_name||' - '||SUM(oi.quantity)||' x '||to_char(p.list_price,'L999G99')||''
product,
SUM(oi.quantity * oi.unit_price) sales, p.product_id
from demo_order_items oi, demo_product_info p
where oi.product_id = p.product_id
group by p.product_id, p.product_name, p.list_price
order by 2 Desc
8. Click on the Report Attributes tab and set the following attributes:
9. In Column Attributes section, edit column Product by clicking the pencil icon to its left
10. Go to Column Link section, set the following attributes and apply changes
Note: The above link will work when we create Page 6 in Chapter 5.
7. Edit the newly created region, Top Orders by Date, and set the following attribute:
8. Click on the Report Attributes tab and set the following attributes:
Note: Since we have not yet created the corresponding pages, the list is attached to, an error
will be displayed when you click on any of the above links displaying page not found message.
These links will be effective after we create relevant pages in chapters 6, 4, and 5 respectively.
We have created all the six regions of our Home page. In the next section, we will create buttons that
will be linked to relevant pages in our applications.
3.4 Summary
Congratulations! You’ve created your first professional looking page in APEX. In this chapter we
learned the following techniques while creating this page:
- Presented data for management information
- Graphical presentation of data
- Formed a dashboard to create multiple types of regions on different positions to display
database and static data
- Created linked columns to show details
- Implemented drilldown functionality to switch to other pages in the application using links and
buttons
14. Enter Customer Details in Entry Name under Create Breadcrumb Entry section, click Next
15. Select CUSTOMER_ID for Primary Key Column 1, click Next
16. Click Existing Sequence icon, select DEMO_CUST_SEQ for Sequence, click Next
17. In Select Column(s) select all columns, click Next
18. Select Yes for Insert, Update, and Delete and click Next
19. Click Finish
20. Click Edit Page
21. Click Application 101 breadcrumb, two pages, 2-Customers and 7-Customer Details, have
been created.
22. Click 2-Customers page
Note: We will use Application 101 throughout this book for our APEX Sample Application ID
2. Click Run to test page number 2. Enter demo and asa in username and password
respectively in the login page. The page will look like Figure 4-1
3. Click the Create Customer button. Customer Details page (Page 7) appears.
Figure 4-2
11. Move up to the Column Attributes section, edit the following columns and Apply
Changes:
12. Click Apply Changes to save region attributes
5. In Enter HTML Text Region Source: enter the following text and click Next
<p>Enter the new customer details. Please ensure these details are correct as they are
used for ordering and invoicing.</p>
<p>Where possible obtain the customer phone number(s) to aid in contacting the customer
at a later date.</p>
We created a list of values STATES in Chapter 2 section 2.5.8(d). Here we’re going to use that list.
We will change customer’s state field from Text to a Select List.
7. In Error Message enter, Can't delete customer with existing orders and click Next
8. Select DELETE (Delete) from When Button Pressed list
9. Click Create button
Figure 4-3
4.6 Summary
We learned the following techniques in this chapter:
- Linking master page to the detail
- Show order details for the selected customer
- Enable order detail link for the user who entered the order
- Created validation to prevent customer record deletion having existing orders
- Implemented Credit Limit check
7. Enter Products in Entry Name under Create Breadcrumb Entry section, clickHome under
Select Parent Entry, and click Next
8. Click on Use an existing tab set and reuse an existing tab within that tab set, select
Tab Set TS1, click Next
9. Select T_PRODUCTS for Use Tab, click Next
10. In Select Column list select the following columns using Ctrl+Click:
Product_Name, Product_Description, Category, Product_Avail, List_Price,
Product_Image
11. Click Next
12. Select any edit link image and click Next
13. In Create form Page set the following attributes:
14. Enter Product Details in Entry Name under Create Breadcrumb Entry section, click Next
15. Select PRODUCT_ID for Primary Key Column 1, click Next
16. Click Existing Sequence icon, select DEMO_PROD_SEQ for Sequence, click Next
17. In Select Column(s) select all columns except MIMETYPE, FILENAME, and
IMAGE_LAST_UPDATE, click Next
18. Select Yes for Insert, Update, and Delete and click Next
19. Click Finish
20. Click Edit Page
21. Click the Application 101 breadcrumb, two pages, 3-Products and 6-Product Details, have
been created.
22. Click the 3-Products page
10. Edit the last four columns and apply the following attributes:
11. Scroll down to Icon View Section and set the following attributes:
12. In Detail View section set Detail View Enabled to Yes
13. In Before Rows enter the following script:
We created a list of values CATEGORIES in Chapter 2 section 2.5.8(a). Here we’re going to use that
list. We will change the Category field from Text to a Select List.
Next, we will change PRODUCT_AVAIL field to Radio Group with two options Yes and No. This
LOV was also created in chapter 2 section 2.5.8(e).
Figure 5-4
Test by adding, modifying, and deleting a new product. Use the Browse button to upload product
image.
5.6 Summary
We learned the following techniques in this chapter:
- How to create Icon, Report, and Detail views to display products
- Displayed top selling products with the selling figures
- Handling images. Upload, delete, and view images to and from database tables
- Used dynamic and static LOVs to store legitimate data in tables
11. Click Use an existing tab set and reuse an existing tab within that tab set., click Next
12. Select T_ORDERS:label=”ORDERS” and click Next
13. Click Create
14. Click Edit Page
1. Click in Regions section and click Delete button and confirm to delete the region
2. Go to Page 4
select
o.order_id,
to_date(to_char(o.order_timestamp,'mm yyyy'), 'mm yyyy') order_month,
o.order_timestamp order_date,
u.user_name sales_rep,
o.order_total,
c.cust_last_name || ', ' || c.cust_first_name customer_name,
(select count(*) from demo_order_items oi where oi.order_id = o.order_id)
order_items
from
demo_orders o,
demo_customers c,
demo_users u
where
o.customer_id = c.customer_id
and o.user_id = u.user_id
A. Report View
1. Click Actions > Save Report > As Default Report Setting > select Alternative, in Name
enter Monthly Review and click Apply
2. In Reports drop down list select 2. Monthly Review
3. Click Actions and then Select Columns
4. Move Order Month to Display in Report section, click Apply
5. Click Actions > Format > Control Break > Select Order Month in row 1 under Column, set
Status to Enabled and click Apply
6. Click Actions > Format > Aggregate > Select Average for Function > Order Total for
Column and click Apply
7. Click Actions > Format > Highlight, type Orders $2,000 in Name, set Highlight Type to
Cell, click [green] for Background Color, click [blue] for Text Color, in Highlight Condition set
Column to Order Total, Operator to (greater than), Expression to 2000 and click Apply
8. Click Actions > Format > Highlight, type Orders $900 in Name, set Highlight Type to Row,
click [yellow] for Background Color, click [Red] for Text Color, in Highlight Condition set
Column to Order Total, Operator to (less than or equal to), Expression to 900 and click Apply
9. Click Actions > Format > Sort > Select Order # in row 1 under column and click Apply
The chart should look like Figure 6-5. If the chart doesn’t appear, click the icon in the search
bar. Move your mouse over each bar to see total amount for the month.
Figure 6-5
C. Group By View
Figure 6-7
4. Click Actions
5. Click Save Report
6. As Default Report Setting
7. Select Alternative, the Name should be Monthly Review
8. Click Apply
6.3.5 Create Public Report
This type of report can be saved, renamed, or deleted by the end user who created it. Other users can
view and save the layout as another report.
A. Report View
Figure 6-8
B. Chart View
1. Click Actions
2. Click Format
3. Click Chart
4. Select the 1st option in Chart Type
5. Select Customer Name for Label
6. Enter Customer in Axis Title for Label
7. Select Order Total for Value
8. Enter Average Order Total in Axis Title for Value
9. Select Average for Function
10. Select Label-Ascending for Sort
11. Click Apply
Figure 6-9
C. Group By View
1. Click to switch back to Report View
2. Click Actions > Format > Group By
3. Set attributes as show in Figure 6-10, click Apply
Figure 6-10
4. Click Actions > Save Report > As Named Report > Alternative, the Name should
contain Customer Review, Public should be checked, click Apply
Figure 6-12
4. Enter Customer Info in Label, set Label Alignment to Right top, Field Alignment to Left,
Label Template to Optional, click Next
Edit all the items individually and set the corresponding attributes shown under each item.
1. Edit the newly created item, P29_CUSTOMER_INFO, scroll down to Security section
and set Escape special characters to No
2. P29_ORDER_TIMESTAMP
3. P29_ORDER_TOTAL
4. P29_USER_ID
5. P29_ORDER_ID_NEXT
6. P29_ORDER_ID_PREV
7. P29_ORDER_ID_COUNT
8. P29_CUSTOMER_ID
9. P29_ORDER_ID
The page is ready. Try adding more products, delete a few and check the page’s functionality. We use
these two pages to manipulate existing orders; in the next sections we will create pages to enter new
orders.
Figure 6-13
Figure 6-14
Figure 6-15
We have to remove Delete and Create buttons in the Buttons section. But before that, we have to
remove few Processes, since these processes have reference to the two buttons.
15. Select Region Template Position #CHANGE# in Position and click Next
16. Click Create Button
17. Edit the newly created button
18. Select SQL Insert action in Database Action under Action When Button Clicked
19. Click Apply Changes
6. Click Use an existing tab set and reuse an existing tab within that tab set., click Next
7. Select TS1, click Next
8. Select T_ORDERS:label=”ORDERS” and click Next
9. Click Finish
3. In JavaScript section enter the following function in Function and Global Variable
Declaration:
function productPopup(productID) {
var url;
url = 'f?p=&APP_ID.:20:&SESSION.::::P20_PRODUCT_ID:' + productID;
html_PopUp(url,'ProductInfo',700,400,1,1);
};
4. Enter the following code in HTML Header under HTML Header and Body Attribute and
Apply Changes
6.10.2 Create Region – Select Items
1. Click Create in Regions section
2. Click the PL/SQL Dynamic Content icon
3. Enter Select Items in Title, select Wizard Region for Region Template and click Next
4. In PL/SQL Source type the following code:
5. Click Create Region
12. Select Region Template Position #CREATE# in Position and click Next
13. Click Next to accept the default values
14. In Condition Type select Exists (SQL query returns at least one row) and enter the
following statement in Expression 1:
select 1 from apex_collections where collection_name = 'ORDER'
15. Click Create Button
16. Click Create to create another button
17. Click Select Item (1) 11 and click Next
18. Click Create a button in a region position
19. Enter PREVIOUS in Button Name and < Previous in Label, click Next
20. Select Region Template Position #PREVIOUS# in Position and click Next
21. Select No for Execute Validations and click Next
22. Click Create Button
Click the Place Order button. This action will cause error ERR-1002 Unable to find item ID for item
"P14_ORDER_ID" in application "103" indicating missing Page 14, the Order Summary page.
Similarly, if you click on Business Shirt link, you will get ERR-1016 Application "103" Page "20"
not found (requested language="en") error which refers to Product Information page - Page 20. In the
next sections we will create these two pages to complete our order placement exercises.
Figure 6-20
9. Set Report Template to default: vertical report, look 2 (exclude null columns),
Pagination Scheme to No Pagination Selected, and Enable Partial Page Refresh to No
Figure 6-21
6. Click Use an existing tab set and reuse an existing tab within that tab set., click Next
7. Click View Orders button in the Order Summary Page to move to Orders main page. The
newly created order should appear on top of the orders list
8. Click to edit the new created order. The page should look like figure 6-14 displayed
earlier in this chapter. Try to add or remove products on this page and save your modifications.
6.16 Summary
The lengthy chapter of the book demonstrated the following techniques:
- Utilization of wizard using Order Progress list
- Created master/detail forms
- Created Primary and Alternative reports
- Created Public Reports
- Report, Chart, and Group by views of data
- Use of Control Break, Highlight, and Aggregate functions
- Drill down to data entry page from report
- Graphical presentation of data
- Added Processes in Page Rendering
- Created a new customer without leaving the order’s page
- Utilized Dynamic Actions to Show/Hide page item
- How to use style in pages
- Usage of PL/SQL code in pages
- Call a popup window to display information
- Summarize data
3. Click Finish
4. Page Zero’s definitions appear
6. Click List
7. Enter Reports in Title, set Template to Navigation Region, Display Point to Page Template
Region Position 3 and click Next
8. Set List to Reports Tab
9. Set Condition Type to Current Page Is Contained Within Expression 1 (comma delimited list
of pages) and enter 5,10,13,16,17,19 in Expression 1
Now we can create the reports to present data graphically. Let’s start with the Customers Order
report.
6. Select Use an existing tab set and reuse an existing tab within that tab set., and click
Next
7. Select TS1, click Next
12. Select T_REPORTS, click Next
13. Click Finish
14. Click Edit Page icon
Figure 7-3
8. In Enter SQL Query type the following statement:
select 'f?
p=&APP_ID.:7:'||:app_session||':::7:P7_CUSTOMER_ID:'||c.customer_id||',17:' link,
c.cust_last_name||', '||c.cust_first_name Customer_Name,
sum (decode(p.category,'Accessories',oi.quantity * oi.unit_price,0))
"Accessories",
sum (decode(p.category,'Mens',oi.quantity * oi.unit_price,0)) "Mens",
sum (decode(p.category,'Womens',oi.quantity * oi.unit_price,0)) "Womens"
from demo_customers c
, demo_orders o
, demo_order_items oi
, demo_product_info p
where c.customer_id = o.customer_id
and o.order_id = oi.order_id
and oi.product_id = p.product_id
group by c.customer_id, c.cust_last_name, c.cust_first_name
order by c.cust_last_name
Move your cursor over the chart bars and different portions within a particular bar. You will see a
tooltip showing order amount of the corresponding customer.
Figure 7-4
6. Select Use an existing tab set and reuse an existing tab within that tab set., and click
Next
7. Select TS1, click Next
8. Select T_REPORTS, click Next
9. Click Finish
10. Click Edit Page icon
Figure 7-6
8. In Enter SQL Query write the following statement:
select null, p.category label, sum(o.order_total)
from demo_orders o, demo_order_items oi, demo_product_info p
where o.order_id = oi.order_id
and oi.product_id = p.product_id
group by category order by 3 desc
The screen should look like Figure 7-7. The chart displays graphical data for the sold Categories.
Move the mouse cursor over Accessories in the pie chart. You will see the amount of orders placed
for Accessories. Switch to other two areas to see sales figures for the respective categories.
Figure 7-7
The chart should look like Figure 7-9. The page now has two regions displaying graphical data for
category and product sales. Move the mouse cursor over each bar and see respective sales figures.
Click on the bar representing Bag’s data, the system will drill you down to the products page to show
you product’s details.
Figure 7-9
Figure 7-10
8. In Enter SQL Query write the following statement:
Figure 7-11
6. Select Use an existing tab set and reuse an existing tab within that tab set., select TS1,
and click Next
7. Select T_REPORTS, click Next
8. In Enter SQL Query type the following statement:
9. In the next screen, the Date Column is set to ORDER_TIMESTAMP and Display Column
to ORD
10. Click Next
11. Click Finish
12. Click Run Page icon
The report should look like Figure 7-13. Click Albert Lambert’s name link in the calendar report to
drill down and browse his order details. Click the browser’s back button. Try and test Weekly,
Daily, Previous, Today and Next buttons and see respective functionalities.
Figure 7-13
Figure 7-14
5. Expand the Country folder and click on States (Click the word “States” to
proceed)
6. Fill the next screen as shown in Figure 7-15 and click Next
Figure 7-15
The page should look like Figure 7-16. This map shows number of customers in any particular
state. Clicking any state link will take you to the customers’ main page to display records of that
state’s customers. Click the Illinois state marked as IL-2, the page will show the two customers
in the state.
Figure 7-16
Figure 7-17
5. Select Use an existing tab set and reuse an existing tab within that tab set., select TS1,
and click Next
6. Select T_REPORTS, click Next
7. Enter Product Order Tree in Tree Name and click Next
8. In Tree Template click on Default
9. Accept ASA as the Table/View Owner and click Next
10. Select DEMO_PRODUCT_INFO for Table and click Next
11. Click Next twice to accept the default values in respective forms
12. In the final form put checks on Collapse All and Expand All to include these buttons. Set
Tooltip to Static Assignment (value equals Tooltip Source attribute) and enter View in
Tooltip Source, click Next
13. Click Finish
14. Click Edit Page
15. Click the Tree link under Regions
16. Replace the existing statement in Tree Query with the following and apply changes:
with data as (
select 'M' as link_type,
null as parent,
'All Categories' as id,
'All Categories' as name,
null as sub_id
from demo_product_info
union
select distinct('C') as link_type,
'All Categories' as parent,
category as id,
category as name,
null as sub_id
from demo_product_info
union
select 'P' as link_type,
category parent,
to_char(product_id) id,
product_name as name,
product_id as sub_id
from demo_product_info
union
select 'O' as link_type,
to_char(product_id) as parent,
null as id,
(select c.cust_first_name || ' ' || c.cust_last_name
from demo_customers c, demo_orders o
where c.customer_id = o.customer_id
and o.order_id = oi.order_id ) || ', ordered '||to_char(oi.quantity) as name,
order_id as sub_id
from demo_order_items oi
)
select case when connect_by_isleaf = 1 then 0
when level = 1 then 1
else -1
end as status,
level,
name as title,
null as icon,
id as value,
'View' as tooltip,
case when link_type = 'M'
then 'f?p='||:APP_ID||':3:'||:APP_SESSION||'::NO:RIR'
when link_type = 'C'
then 'f?p='||:APP_ID||':3:'||:APP_SESSION||'::NO:CIR:IR_CATEGORY:'
||name
when link_type = 'P'
then 'f?p='||:APP_ID||':6:'||:APP_SESSION||'::NO::P6_PRODUCT_ID:'
||sub_id
when link_type = 'O'
then 'f?p='||:APP_ID||':29:'||:APP_SESSION||'::NO::P29_ORDER_ID:'
|| sub_id
else null
end as link
from data
start with parent is null
connect by prior id = parent
order siblings by name
Click the small arrow in All Categories to expand the tree. Expand other branches as shown in Figure
7-18. The tree view has three levels as indicated in the figure. Clicking the branch links will drill
down to browse the details. Click the All Categories link to open the Products main page. Move back
using the browser’s back button. Click on Men’s branch. All men products will be displayed. Click
on Trousers, product details page opens to show its details. Under the Trouser branch, click Albert
Lambert’s link, Order Details page appears displaying the trousers ordered by him.
7.9 Summary
Reports are the most significant components of any application that allows to dig information from the
data mine to make decisions. This chapter not only demonstrated the power of Oracle Application
Express to graphically present the information but also exhibited how to drill down to a deeper level
to obtain detailed information. We learned:
- Dunning Letters
To print these professional reports, you have to pay for a valid Oracle BI Publisher license that is
worth the price considering the following advantages:
-- Before checking the privilege, make sure that the ACL is valid
-- (for example, does not contain stale references to dropped users).
-- If it does, the following exception will be raised:
--
-- ORA-44416: Invalid ACL: Unresolved principal 'APEX_040000'
-- ORA-06512: at "XDB.DBMS_XDBZ", line ...
--
DBMS_XDBZ.ValidateACL(ACL_ID);
IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PAT
'APEX_040000',
'connect') IS NULL THEN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
'APEX_040000', TRUE, 'connect');
END IF;
EXCEPTION
-- When no ACL has been assigned to 'localhost'.
WHEN NO_DATA_FOUND THEN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('local-access-users.xml',
'ACL that lets power users to connect to everywhere',
'APEX_040000', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('local-access-users.xml','localhost');
END;
/
COMMIT;
-- Before checking the privilege, make sure that the ACL is valid
-- (for example, does not contain stale references to dropped users).
-- If it does, the following exception will be raised:
--
-- ORA-44416: Invalid ACL: Unresolved principal 'APEX_040000'
-- ORA-06512: at "XDB.DBMS_XDBZ", line ...
--
SELECT SYS_OP_R2O(extractValue(P.RES, '/Resource/XMLRef')) INTO ACL_ID
FROM XDB.XDB$ACL A, PATH_VIEW P
WHERE extractValue(P.RES, '/Resource/XMLRef') = REF(A) AND
EQUALS_PATH(P.RES, ACL_PATH) = 1;
DBMS_XDBZ.ValidateACL(ACL_ID);
IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PAT
'APEX_040000',
'connect') IS NULL THEN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
'APEX_040000', TRUE, 'connect');
END IF;
EXCEPTION
-- When no ACL has been assigned to '*'.
WHEN NO_DATA_FOUND THEN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
'ACL that lets power users to connect to everywhere',
'APEX_040000', TRUE, 'connect');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;
Figure 8-1
select
o.order_id,
to_char(o.order_timestamp,'Month yyyy') order_month,
o.order_timestamp order_date,
c.cust_last_name || ', ' || c.cust_first_name customer_name, c.cust_state,
u.user_name sales_rep,
(select count(*) from demo_order_items oi where oi.order_id = o.order_id)
order_items,
o.order_total
from
demo_orders o,
demo_customers c,
demo_users u
where
o.customer_id = c.customer_id
and o.user_id = u.user_id
6. Select XML Data for Data Source for Report Layout, click the Download button, select
Save File, and click OK. A file named Monthly_Review.xml will be saved to your disk.
7. Click the Create Report Query button
8. Click Test Report. If the BI Publisher server is down, you will see the error ORA-29273:
HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1324 ORA-12570: TNS:pack
reader failure. Start the server and try again. In the popup dialog box, select Open with Adobe
Acrobat and click OK. A generic PDF output similar to Figure 8-3 appears. Click Finish.
Figure 8-3
9. Select Order Month in the first drop down list under Group By and click Next
10. Select Order ID for sorting data, click Next
11. Change Cust State label to State
12. Click Finish. An output similar to Figure 8-4 will be displayed.
Figure 8-4
13. Save the template, enter Monthly_Review in the File name, select Rich Text Format as
the Save as type and click Save
14. Click Preview and select PDF. The output as show in Figure 8-5 is displayed.
Figure 8-5
Use the same procedure and change font and background color for orders greater than 2000. Select
Greater than for the condition and enter 2000 in the value. After completion, preview the report to
check your work.
4. Right click the chart in MS Word and select Insert Caption. Type Monthly Orders Chart
in Caption.
Figure 8-8
4. Close the preview. Save the template and close MS Word.
That's it. You have created a professional looking report template in MS Word. It’s easy, isn't it? In
the next section, we are going to integrate the template by uploading this layout to our APEX
application.
We created the Report Layout in APEX by uploading the MS Word Template and linked it to our
Report Query. In the next section we will create a button on our Orders page to run the Monthly
Orders Review report.
Figure 8-11
5. In SQL Query enter the following statement and click Next:
select oi.ORDER_ITEM_ID, pi.PRODUCT_NAME, oi.UNIT_PRICE, oi.QUANTIT
oi.Unit_Price * oi.Quantity as Amount, c.cust_first_name || ' ' || c.cust_last_name as
customer, c.cust_street_address1, c.cust_street_address2, c.cust_city, c.cust_state,
c.cust_postal_code, u.user_name
from DEMO_ORDER_ITEMS oi, DEMO_PRODUCT_INFO
DEMO_CUSTOMERS c, DEMO_USERS u
where pi.PRODUCT_ID=oi.PRODUCT_ID and ORDER_id = :P29_ORDER_ID a
customer_id = :P29_CUSTOMER_ID and user_id = :P29_USER_ID
6. Select XML Data for Report Layout Data Source, click the Download button and save the
file Invoice.xml to your hard drive.
7. Click Create Report Query
8. Test the output and click Finish
8.10.2 Create Invoice Template in MS Word
You have the option to create the template yourself or use one from the templates provided in MS
Word.
1. Open MS Word
2. Click New on the main menu
3. From the Templates pane select Invoices, selected Sales Invoices from the middle pane,
select an invoice template and click the Download button. The invoice template will appear in
MS Word.
4. Click the Add-Ins menu and load XML data by selecting Invoice.xml file
5. Click Insert, select Field, drag P29_Order_Id and drop it in the box labeled INVOICE #.
Drop Order_Timestamp, User Name, Customer ID, Customer, Address1, Address2, City,
State and Postal Code fields to their respective boxes.
6. Click Insert, Table Wizard, Table and click Next
7. For Data Set select Document/Region/RowSet/Row option and click Next
8. Select fields Product Name, Quantity, Unit Price, and Amount and move them to the
right pane and click Finish
9. Drop the field Order Total in the summary section next to Total Amount
10. Format the template and its fields and save it as Invoice.rtf
1. Go to Shared Components
2. Click Report Layout
3. Click Create
4. Select Named Columns (RTF)
5. Type Invoice in Layout Name
6. Click the Browse button and select Invoice.rft file
7. Click the Shared Components breadcrumb
8. Click Report Queries
9. Click the Invoice query
10. Select Invoice for Report Layout
11. Click Apply Changes
In this section we will add a button, named Print Invoice, and a branch to the Order Detail page to run
the invoice.
8.11 Summary
Complex printing is the essence of modern applications that lacked in initial APEX versions. The
introduction of print server has bridged this gap to create any kind of report to monitor your business
activities in real time. This chapter provided you the following essential information to fulfill your
reporting needs:
-- Finally, we compare them to see if they are the same and return
-- either TRUE or FALSE
if l_password = l_stored_password then
return true;
else
return false;
end if;
else
return false;
end if;
else
-- The username provided is not in the DEMO_USERS table
return false;
end if;
end;
l_password := utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5
(input_string => p_password || substr(l_salt,10,13) || p_username ||
substr(l_salt, 4,10)));
return l_password;
end;
12. Go to Column Link section, set the following attributes and apply changes:
7. In Error Message type Your passwords must be the same. Please re-enter.
8. Click Next
9. Click Create
10. Edit the newly created validation
11. Scroll down to Error Message section and set Associate Item to P9_NEW_PW and apply
changes
5. Click Next
6. In Success Message type Password for &P9_USER_NAME. Updated.
7. Click Create Process
Figure 9-2
3. Click the Reset Password link for the user DEMO. The password reset page should be
displayed as shown in Figure 9-3.
Figure 9-3
4. Enter demo in Enter New Password and Re-Enter New Password, and click theReset
Password button. Password for DEMO updated, message appears. Please note that the
passwords are case sensitive.
5. Click the Add User button. A blank row will appear.
6. Enter the following values and click the Save Changes button:
7. The Reset Password column value for the newly created user, TEST, is set to SET PASSWORD
indicating a new user. Click SET PASSWORD link to set password for the user TEST.
8. Enter test in Enter New Password and Re-Enter New Password, and click theReset Password
button. Once again the update password message appears.
9. Click the logout link in the navigation bar.
10. Enter TEST and test in username and password to login.
11. Click the Administration Tab.
12. You will get Access denied by Page security check. You need to be an Admin User in order
to view this page message. Click the OK button to move back.
13. Click the Products tab. Note that the Create Products button is not visible because we set NO
for Edit Product for the user TEST to prevent him from manipulating products data.
Figure 9-4
You can enter follow up for the received feedback, log it as a bug, as a To-do, and as a feature. Click
on the calendar tab to see number of feedbacks along with application ID. Check the other tabs that
graphically present feedback statistics.
9.7 Summary
You were taught the following skills in this chapter:
This chapter concludes our effort to build a professional looking web application in Oracle
Application Express. It’s the time to give it a complete run prior to deploying it to a test or production
machine. In the final part of this book, you will learn how to move this application from your
computer to another environment and how to access the application.
Chapter 10 - Deploy and Access APEX Application
10.1 About Application Deployment
APEX application deployment consists of two steps. Export the desired components to a script file,
and import the script file into your production environment. Till now, you were running the
application on your computer. Having completed the development phase, you will definitely run the
application in a production environment. For this, you have to decide where and how the application
will run. The following section provides you some deployment options to choose from.
10.1.1 No Deployment: The development environment becomes the production environment and
nothing is moved to another computer. In this option users are provided just the URL to access
application.
10.1.2 Application: You will use this option if the target computer is already running a production
Oracle database with all underlying objects. You only need to export the application and import it
into the target database.
10.1.3 Application and Table Structures: In this deployment option you have to create two scripts,
one for your application and another for the database table structures using Generate DDL utility in
SQL Workshop.
10.1.4 Application, Database Objects with Data: We are going to use this option to deploy our
application along with all database objects and will utilize oracle's data pump utility to export data
from the development machine to the production environment.
10.1.5 Individual Components: With the development phase going on, you can supplement your
deployment plan with the export of selective components. We will see how this option can be used
when we will export our application logo.
For simplicity, we will deploy the application on the same development computer using another
schema and workspace to understand the deployment concept. The same technique is applicable to the
production environment.
In this exercise the following tasks will be performed:
- Export application from the existing workspace, ASA
- Export data from the existing schema, ASA, using Oracle’s data pump utility
- Export application logo to demonstrate selective component export
- Create a new Workspace, ASACLONE, to hold the application
- Create a new Oracle user, ASACLONE, to hold the backed up database objects
- Access the application in LAN and through the internet
Figure 10-1
We will be using Oracle’s export and import data pump utilities to achieve the task.
1. Create a folder named datapump under the database folder like this C:\OracleXE\datapump.
2. Run the SQL Command Line utility using Start > All Program > Oracle Database 11g Express
Edition
3. On the SQL prompt type connect system/manager and press Enter. The connected message
appears.
4. On the SQL prompt type create directory datapump as ‘c:\oraclexe\datapump’; and press
Enter. Directory Created message appears.
5. Open a command prompt using Start > Run > type cmd in the Open box and click OK
6. T y p e cd c:\oraclexe\datapump and press Enter. The prompt should look like
C:\OracleXE\datapump>.
7. Ty p e ExpDP system/manager schemas=ASA directory=datapump dumpfile=ASA.dmp
logfile=ASAexport.log and press Enter. Successfully completed message should appear.
10.4 Export Selective Component
In the following steps we will export our application’s logo to demonstrate how individual
components can be exported in APEX.
If required in future, the following steps will be performed to unlock the locked application.
Figure 10-3
That’s it. We have successfully deployed our application on the same computer but in a different
workspace and schema. You can apply the same procedure to deploy the application in another
environment. In the next section we will try to connect this application in a LAN environment as well
as from the internet. It is assumed that you have deployed the application on a computer having two
network interface cards with static IP. One connected to the local area network and the other
connected to a DSL modem.
1. Office LAN
2. Database Server
3. LAN Clients
4. NIC-1 with static local IP 10.1.1.12
5. NIC-2 with static external IP 255.266.204.231
6. Remote Client
This scenario assumes that you have a computer, to act as the application server, with the following
components:
- Windows XP or higher OS
- Oracle Express Edition (XE) 11g
- APEX Sample Application deployed and running locally
- Two network interface cards, with static IP, connected to local area network and the internet
Perform the following steps to get the IP addresses of the server computer. In this scenario we will be
using 10.1.1.12 for the LAN and 255.266.204.231 for the internet.
1. Right-click the LAN connection in the task bar and click Open Network Connections
1. Open a browser session and type http://10.1.1.12:8080/apex/f?p=117 (replace 117 with your
application ID)
2. Type demo, demo for the Username and Password respectively
You may get an error message at this stage as show in Figure 10-5, indicating your computer or
network is protected by a firewall. If so, you need to create an exception in the Windows
Firewall to accept incoming connection on the APEX port that is 8080 in our scenario.
Figure 10-5
1. In Windows, click Start, click on Control Panel, and double click Windows Firewall icon
2. Click on the Exceptions tab
3. Click the Add Port button
4. Type APEX Port in Name, 8080 in Number, select TCP and click OK
5. Click OK to close the Windows Firewall dialog box
APEX Port exception is added to the Program and Services section which will now allow you to
access the application.
If you followed the instructions correctly, you will definitely access the application internally as well
as remotely. This chapter taught you the implementation process of your application. You saw how
easy it was to take the application from your development PC to the production environment. Besides
application access scenario, we also resolved the firewall issues that might prevent you from
accessing the application.
10.12 Conclusion
I hope this book has provided you a solid foundation of Oracle Application Express and set a firm
ground to develop robust application systems to fulfill the information requirements of your
organization. The sky is the limit, you are limited by your imagination. Be creative, and put the power
of APEX to your work. Good luck.