Upload
others
View
26
Download
0
Embed Size (px)
Citation preview
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
1
Autonomous Database for
APEX Developers
Hands on Lab Guide
Part 2
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
2
Table of Contents Lab Introduction .......................................................................................................................... 4
Lab Pre-requisites ................................................................................................................... 4
Getting support during the online lab session ................................................................. 5
Getting Started and Lab 100 (Run Once) ............................................................................... 6
Download the lab script bundle ........................................................................................... 6
Create your Oracle Cloud Trial Account ............................................................................ 6
Lab 100 - Provision your Autonomous Database ......................................................... 10
About Configuring Auto-Scaling in the Autonomous Database ........................... 16
Accessing the Performance Hub ................................................................................... 17
Prepare the APEX Workspace ........................................................................................ 19
Create an Oracle Analytics Cloud (OAC) instance to prepare for Lab 500 .............. 23
Lab 400: Adding Security to an APEX application ........................................................... 27
Checking your current encryption status ........................................................................ 27
Securing your sensitive information using data redaction ........................................ 30
Populate the Lab Schema .............................................................................................. 30
Create the simple application ......................................................................................... 32
Lab 500: Adding Analytics to your APEX application ...................................................... 38
Import the APEX application ............................................................................................. 38
Review the 'Time and Labor' APEX application ............................................................ 42
Create the connection from Oracle Analytics Cloud to Autonomous Database ... 44
Download your Autonomous Database wallet ......................................................... 44
Use the Wallet in Oracle Analytics Cloud .................................................................... 46
Prepare the dataset .............................................................................................................. 48
Create Self-Service analysis ................................................................................................ 53
Embed the OAC Data Visualization project into APEX ................................................ 69
Want to learn more about APEX? ......................................................................................... 80
Appendix A – Provisioning an Oracle Analytics Cloud Instance .................................... 81
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
3
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
4
Lab Introduction
In this hands-on lab you will get first-hand experience of using Oracle Autonomous
Database (ADB) and Oracle Application Express (APEX). The lab is split into 2 parts
to allow it to be delivered in a virtual classroom environment.
Oracle Autonomous Database (ADB) delivers a self-driving, self-securing, self-
repairing database service that can instantly scale to meet demands. The service
supports two workload types:
• Oracle Autonomous Data Warehouse (ADW) provides an autonomous
warehousing environment, associated with fast query performance.
• Oracle Autonomous Transaction Processing (ATP) provides an autonomous
online transaction processing and mixed workload environment.
Oracle Application Express (APEX) is a low-code development platform that
enables you to build scalable, secure enterprise apps, with world-class features,
that can be deployed anywhere.
The lab is structured in several sections. Everyone must complete the "Getting
Started and Lab 100" section, but after that the individual APEX Labs are
standalone.
The lab has been produced based on the labs located at
https://github.com/oracle/cloudtestdrive/tree/master/ATP/APEX
Lab Pre-requisites
This lab requires you to install the following desktop applications so that you can
complete this hands-on lab:
• PDF File reader.
• A web browser. The lab guide was created using Google Chrome.
As you will be registering for services in Oracle Cloud, you will also need
• Access to the email account used to register for the workshop.
• A cell phone to receive an SMS for account verification processes.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
5
Getting support during the online lab session
This workshop is delivered over Zoom, with panellists on standby to answer your
questions via the Q&A tab. The Q&A tab does not allow screenshots to be shared.
To get the best detailed help with your problem please provide some basic
information in your question such as:
• Region of your tenancy
• Database Version
Page of the lab guide where you are experiencing the problem.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
6
Getting Started and Lab 100 (Run
Once) If you have completed 'Getting Started and Lab 100' in Part 1 of the Lab
document and have provisioned your Oracle Analytics Cloud instance in
preparation for Lab 500 you do not need to complete this section again, you
can proceed to Lab 400.
This section of the lab will take you through all the required preparation steps. You
will
• Download the lab scripts.
• Create and connect to your Oracle Cloud account.
• Create your Autonomous Database.
• Configure your Autonomous Database.
• Prepare your APEX Workspace.
Download the lab script bundle
All of the sql scripts and large code blocks for this lab are available as a zip file
https://bit.ly/2rdAHCn . Download and unzip this bundle on your laptop.
Create your Oracle Cloud Trial Account
During this workshop you will use an Oracle Cloud Free Tier Account to run the Lab
exercises. This account will give you access to the Always Free resources in Oracle
Cloud Free Tier and a limited time trial period with an expanded set of services.
Once this period elapses, you can continue to use the Always Free resources with
no interruptions.
Always Free and Free Trial instances can be seamlessly upgraded to paid at any
time. Existing Oracle Cloud customers have access to Always Free services
automatically—no new sign up required.
As part of your sign up to this lab you will have been provided a link to sign up to
Oracle Cloud Free Tier. Please make sure you:
• Use the exact URL provided by your lab leader.
• Use the same email address that you used to register for the workshop.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
7
Enter your email address and select "Next".
On the "Account Detail" page you will be asked for the Cloud Account Name (also
known as Tenancy Name). This will uniquely identify your cloud environment and
will be visible in your URL later, so please choose wisely.
You will also be asked for the "Home Region". This is the location of the physical
datacenter. Select "UK South ( London ) " or "Germany Central (Frankfurt)", as
these datacenters offer the Autonomous Database Always Free service. See
https://www.oracle.com/cloud/data-regions.html#emea for updates to service
availability in other regions.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
8
Complete all other mandatory fields on the form (indicated with a * ) and select
Next: Verify Your Mobile Phone Number.
You will be prompted to enter the code sent to your cellphone.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
9
At the end of this process, you will receive an email titled "Get Started Now With
Oracle Cloud". This will contain all the information you need to sign into your cloud
account and include a link to the login page for your region.
To login to your cloud account, use the same email address that you used for
registration and the password provided in the email. You will be prompted to set a
new, more memorable password.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
10
Lab 100 - Provision your Autonomous Database
Your new cloud tenancy will not have any compartments configured, so by default
you will create objects in the root compartment.
Note: If you want to learn more about administering Oracle Cloud
Infrastructure there are learning resources at
https://www.oracle.com/cloud/iaas/training/foundation.html with
additional hands on labs at https://oracle.github.io/learning-library/oci-
library/
Click on the MENU link at the top left of the page.
This will produce a drop-down menu, where you should select Autonomous
Transaction Processing
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
11
This will take you to the management console page for ATP in the root
compartment of the tenancy.
To create a new instance, click the blue Create Autonomous Database button.
Enter the required information and click the Create Autonomous Database button
at the bottom of the form. For the purposes of this lab, use the information below:
Compartment: Verify that a compartment is selected.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
12
Display Name: Enter the display name for your ATP Instance.
Database Name: Enter any database name you choose that fits the
requirements for ATP. The database name must consist of letters and
numbers only, starting with a letter. The maximum length is 14 characters.
Workload Type: Autonomous Transaction Processing
Deployment Type: Shared Infrastructure
Always Free: On
Choose Database version: 18c
CPU Count: 1
Storage Capacity (TB): 0.02
Auto scaling: off
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
13
Administrator Password: Enter any password you wish to use noting the
specific requirements imposed by ATP. A suggested password for this lab is
ATPwelcome-1234
Configure access control rules: off
Choose a License Type: Licence Included.
When you enter the administrator password, note the specific requirements
imposed by Autonomous Database:
When you have completed the required fields, scroll down and click on the blue
Create Autonomous Database button at the bottom of the form:
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
14
The Autonomous Database Details page will show information about your new
instance. You should notice the various menu buttons that help you manage your
new instance – because the instance is currently being provisioned all the
management buttons are grayed out.
A summary of your instance status is shown in the large box on the left. In this
example, the color is amber and the status is Provisioning
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
15
After a short while the status will change to Available and the “ATP” box will
change color to green:
Once the Lifecycle Status is Available, additional summary information about your
instance is populated, including workload type. You can also see the Lifecycle
Status reported in this region.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
16
The provisioning process should take under 5 minutes.
About Configuring Auto-Scaling in the Autonomous Database
When you select auto scaling Autonomous Database can use up to three times
more CPU and IO resources than specified by the number of OCPUs currently
shown in the Scale Up/Down dialog without any manual intervention required.
On the "Autonomous Database Details" page for your Autonomous Database, click
the Scale Up/Down button.
In an "Always Free" tier database in a tenancy with no credits, the Scale Up/Down
pop up is limited in functionality, as autoscaling requires additional credits.
In a paid tenancy the "Scale Up/Down" pop-up will appear as below.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
17
Enabling auto-scaling, or manually scaling the Autonomous Database is
transparent to the users of the system. Only an administrator will be aware of this
change in progress when the Lifecycle State changes to 'Scaling in Progress'.
Accessing the Performance Hub
Performance Hub allows you to examine real-time and historical performance data,
view Active Session History (ASH) Analytics and SQL Monitoring.
From your Autonomous Database Details page, select Performance Hub from the
Action Menu.
The Performance Hub page consists of the following regions:
- The time Range field and slider
- Active Session History (ASH) analytics tab
- SQL Monitoring Tab.
Your Performance Hub page may not have any monitored SQL sessions available
in the screen. If this is the case, just examine the screenshots and use the menu
bars within the Performance Hub to examine what data you could use.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
18
The Time Range
The "Time Range Selector" is on the top of the Performance Hub page. You can
use the "Select Duration" field to set the time duration displayed. You can choose to
view Last Hour (default), Last 8 hours, Last 24 hours, Last week, or specify a
custom time range using the Custom option.
The Time Range field shows active sessions in chart form for the time period
selected. The active sessions chart displays the average number of active sessions
broken down by CPU, User I/O, and Wait. The active sessions chart also shows the
Max CPU usage.
Active Session History (ASH) Analytics
This shows Active Session History (ASH) analytics charts to explore Active Session
History data. You can drill down into database performance across multiple
dimensions such as Consumer Group, Wait Class, SQL ID, and User Name.
SQL Monitoring
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
19
The SQL statements by default are only monitored if they have been running for at
least five seconds or if they have run in parallel.
The table displays the top 100 monitored SQL statement executions, and you can
choose to alter the display by dimensions such as Last Active Time, CPU Time, and
Database Time. You can also choose to kill badly behaved SQL sessions from this
screen.
Prepare the APEX Workspace
Login to APEX Administration Services
From your Autonomous Database Details page, select Service Console from the
Action Menu.
This will open the Service Console in a new browser tab.
In the side menu select Development.
Select Oracle APEX.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
20
This will open a new browser tab for Application Express Administration.
Login as the Admin user, with the Admin password you specified at Autonomous
Database creation time.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
21
Create the Lab Workspace
On the Welcome to "Oracle Application Express" page, select Create Workspace.
Use the following information to fill out the form:
Database User: WORKSHOPATP
Password: Any password that meets the Oracle Cloud requirements.Use
ATPwelcome-1234 for this lab.
Workspace Name: WORKSHOPATP
Select Create Workspace.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
22
You will be returned to the Oracle APEX administration page, and a message will be
displayed "Workspace Created".
Logout as the Admin user by selecting the icon in the top right hand side of the
screen and selecting Sign Out.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
23
Create an Oracle Analytics Cloud (OAC) instance to
prepare for Lab 500
There are currently two methods of deploying OAC instances. This section
describes the process of deploying Oracle Analytics Cloud instances on Oracle
Cloud Infrastructure Gen 2, which is the default for newly provisioned accounts in
EMEA and US. If you want to deploy using the legacy method, please see Appendix
A.
Your Oracle Cloud Free Tier account will use the Oracle Cloud Free Trial credits
while this instance is provisioned, as Oracle Analytics Cloud is not part of the
Always Free cloud services.
Provisioning an Oracle Analytics Cloud instance can take over 40 minutes. If you
plan to run Lab 500 during the classroom session, then you can provision the
instance now and have it ready for use later.
Return to the Oracle Cloud Infrastructure console, click on the menu icon on the
left. Verify that you are signed in as a Single Sign On (idcs) user by selecting the
Profile icon in the top right hand side of your screen. If your username is shown as:
<idcs server name> / <your username> then you are connected as a Single Sign
On user.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
24
If not, please logout and select to authenticate using Single Sign On.
Navigate to Analytics and then Analytics Cloud.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
25
Note: You must be connected as a Single Sign On (idcs) user to a tenancy
which has available cloud credits to see this menu item. Local OCI users are
not able to do this.
Select Create Instance.
Complete the form using the following information:
Compartment: Select a valid compartment in your tenancy.
Instance Name: WORKSHOPATP
Description: <optional>
Feature Set: Enterprise Analytics (important)
Capacity: 1 - Non Production
License Type: "Subscribe to a new Analytics Cloud software license and the
Analytics Cloud." (You will use this service as part of the free Oracle Cloud
trial that you requested for this workshop)
Select Create.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
26
On the Confirmation screen select Create.
The Analytics instance page will be displayed with a status of CREATING.
You can now proceed onto running the labs.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
27
Lab 400: Adding Security to an
APEX application
Oracle Autonomous Database protects against both external attacks and malicious
internal users:
• All data is encrypted at rest using Transparent Data Encryption.
• Network connections from clients to Autonomous Database are also
encrypted using the client credentials wallet. Using client credential wallets
includes both server and client-side authentication and provides the highest
level of security.
• Oracle automatically applies all security updates to ensure data is not
vulnerable to known attack vectors.
• Customers are not given OS logons or SYSDBA privileges to prevent
phishing attacking.
• Additional in-database features like Virtual Private Database and Data
Redaction are also available.
In this lab you will:
• Demonstrate that your user data is stored in encrypted tablespaces.
• Configure Oracle Data Redaction.
Checking your current encryption status
In Autonomous Database the data storage tablespaces are automatically encrypted
using TDE.
From your Autonomous Database Details page, select Service Console from the
Action Menu.
This will open the Service Console in a new browser tab.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
28
In the side menu select Development.
Select SQL Developer Web
Enter the ADMIN username and the password that was used at provisioning time to
login.
Check which tablespaces are encrypted by running the following sql (this code is
available in lab zip file as the text file lab400-encryptedts.sql).
select tablespace_name, status, encrypted from dba_tablespaces;
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
29
There are two encrypted tablespaces in our example, DBFS_DATA and DATA.
These are the tablespaces in the Autonomous Data that store user data.
You can see what algorithm is used to encrypt these tablespaces by examining the
v$encrypted_tablespace view (this code is available in lab zip file as the text file
lab400-encrypt-detail.sql).
select vt.name, et.encryptionalg, et.encryptedts
from v$tablespace vt,
v$encrypted_tablespaces et
where et.ts#=vt.ts#;
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
30
In this database the AES128 algorithm is used for encryption. As an administrator of
an Autonomous Database you cannot change the algorithm in use or make the
user data tablespaces un-encrypted.
Securing your sensitive information using data
redaction
Oracle Data Redaction enables you to mask (redact) data in real time that is
returned from queries issued by applications.
Oracle Database applies the redaction at runtime, when users access the data at
query-execution time. This solution works well in a production system. During the
time that the data is being redacted, all of the data processing is performed
normally, and the back-end referential integrity constraints are preserved.
Populate the Lab Schema
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
31
Using SQL Developer Web, execute the following script (Do not copy and paste this
from this pdf, use the script in the lab zip file, lab400-redact-schema.sql).
This will populate the table holding synthetic credit card information. This table will
be the basis for the APEX application.
grant create session to workshopatp;
grant unlimited tablespace to workshopatp;
drop table workshopatp.credit_card;
create table workshopatp.credit_card
(cust_id number(10) GENERATED ALWAYS AS IDENTITY START WITH 1000,
enroll_date date NOT NULL,card_no number(16) NOT NULL,exp_date date NOT
NULL,card_val varchar2(20));
insert into workshopatp.credit_card(enroll_date,card_no,exp_date,card_val)
values (sysdate,1285145836589848,TRUNC(ADD_MONTHS(SYSDATE,36)),'1111-2222-
3333-4444');
insert into workshopatp.credit_card(enroll_date,card_no,exp_date,card_val)
values (sysdate,8554884663181666,TRUNC(ADD_MONTHS(SYSDATE,36)),'5555-2222-
3333-8888');
insert into workshopatp.credit_card(enroll_date,card_no,exp_date,card_val)
values (sysdate,6543884663181666,TRUNC(ADD_MONTHS(SYSDATE,36)),'9999-1111-
6655-8888');
insert into workshopatp.credit_card(enroll_date,card_no,exp_date,card_val)
values (sysdate,7343884663184583,TRUNC(ADD_MONTHS(SYSDATE,36)),'2222-4444-
6655-1111');
commit;
Verify the data in the table by running the following select statement.
select * from workshopatp.credit_card;
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
32
The table contains 4 rows, with simulated sensitive information such as the number
on the credit card (card_val column).
Create the simple application
Open the APEX login screen. If you do not have a direct link or an open browser
window to this page you can access it by returning to the Service Console of your
Autonomous Database, select Development, and then Apex.
Login to APEX using:
Workspace name: WORKSHOPATP
User name: WORKSHOPATP
Password: Password you selected when creating the workspace.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
33
Click on the App Builder menu bar, then Create.
Select New Application.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
34
Use "RedactApp" as the name of your new Application and click on Add Page.
Select Report in the list of available page types.
Complete the form as follows:
Page Name: Credit Card
Table or View: CREDIT_CARD
Advanced
Set as Home Page: Check
Select Add Page
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
35
Click on Create Application at the bottom of the window. This simple application
creation will take a few moments.
Click on Run Application to see the application without Data Redaction.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
36
Authenticate with the application using:
User name: WORKSHOPATP
Password: Password you selected when creating the workspace.
You will now see the simple application displaying the values from the
CREDIT_CARD table.
The card_val column requires data redaction to avoid exposing the full credit card
numbers to the users of our application.
Update the application to only show the last 4 numbers of the card_val column.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
37
Return to SQL Developer Web and run the following PL/SQL to use the
DBMS_REDACT procedure to add a policy to that column. (Do not copy and paste
this from this pdf, use the script in the lab zip file lab400-redact-policy.sql)
BEGIN
DBMS_REDACT.ADD_POLICY(
object_schema => 'workshopatp',
object_name => 'credit_card',
column_name => 'card_val',
policy_name => 'redact_REG_EXP',
function_type => DBMS_REDACT.PARTIAL,
function_parameters => 'VVVVFVVVVFVVVVFVVVV,VVVV-VVVV-VVVV-
VVVV,*,1,12',
expression => '1=1',
policy_description => 'Partially redacts our credit card numbers',
column_description => 'card_val contains credit card numbers in
VARCHAR2 format');
END;
/
After the code has been executed successfully, refresh the page in your application.
The credit card numbers are now protected by the data redaction. The complete
numbers will not be displayed to users of the application, but the data is left intact
in the underlying table.
You have now completed Lab 400.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
38
Lab 500: Adding Analytics to
your APEX application Oracle Analytics Cloud provides the industry’s most comprehensive cloud analytics
in a single unified platform, including everything from self-service visualization and
powerful inline data preparation to enterprise reporting, advanced analytics, and
self-learning analytics that deliver proactive insights.
You will expand an existing application to add Oracle Analytics functionality.
Imagine that the end user of your application has questions about the billing data.
You could provide them with some fixed, prebuilt charts built into the APEX
application, however that would not allow the end user to create entirely new
analysis. You are going to use an Oracle Analytics Cloud instance to give our end
users a self-service approach to analysing the data.
In this lab you will:
• Create a connection from Oracle Analytics Cloud to Autonomous Database.
• Create Visualizations to analyse the data.
• Add Analytics functionality to your application.
Import the APEX application
Your starting point is an existing time entry application used by a fictional IT
consulting company. It contains basic time and rates of their consultants.
Open the APEX login screen. If you do not have a direct link or an open browser
window to this page you can access it by returning to the Service Console of your
Autonomous Database, select Development, and then Apex.
Login to APEX using:
Workspace name: WORKSHOPATP
User name: WORKSHOPATP
Password: Password you selected when creating the workspace.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
39
As part of the workshop preparation you downloaded a zip file containing the lab
script files. If you have not done so already, unzip this file so you can access the
files it contains.
At the top of the Workspace home page, click the App Builder menu and select
Import.
Use the Choose File button to select 'lab500-application.sql' from the lab scripts
zip file.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
40
On the "File Import Confirmation" screen do not make any changes and select
Next.
On the "Install Database Application" screen no changes are required, select Install
Application.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
41
On the "Install Application – Supporting Objects" screen no changes are required,
select Next.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
42
On the "Install Application – Confirmation" select Install.
On the final screen of the wizard, select Edit Application to be placed into the App
Builder screen.
Review the 'Time and Labor' APEX application
On the App Builder page for your new application, select Run Application
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
43
This will open the Application in a new browser tab.
If prompted, login to the application as WORKSHOPATP with the password you set
for the user.
Click the Time Registrations page. This shows a list of customers, the hours
worked on the engagement, and the employee who did the work.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
44
Use the Home icon and select the Customer Report screen. This is a simple report
giving information about the hours worked for each customer. This report, while
factual, does not give analytical information about the project, and so needs then
enhancement of an Oracle Analytics Cloud Data Visualization.
Create the connection from Oracle Analytics Cloud
to Autonomous Database
Oracle Autonomous Database only accepts secure connections to the database.
This requires a 'wallet' file that contains the SQL*NET configuration files and the
secure connection information. Wallets are used by client utilities such as SQL
Developer, SQL*Plus etc. For this lab you will use this same wallet mechanism to
make a connection from OAC to the Autonomous Database.
Note: This section assumes you have already created your Oracle Analytics
Cloud instance as part of the 'Getting Started' section. If not, please return
there and run the instance creation.
Download your Autonomous Database wallet
On the "Autonomous Database Details" page for your Autonomous Database, click
the DB Connection button.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
45
This will open a pop-up window.
Select Wallet Type Instance Wallet and then Download Wallet.
You will be asked to provide a password for the wallet. The password must meet
the rules for the Oracle Cloud password complexity.
Select Download and save the wallet to your local machine.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
46
You can now Close the Database Connection pop up window.
Use the Wallet in Oracle Analytics Cloud
Return to the Oracle Cloud Infrastructure console, click on the hamburger menu
icon on the top left.
Navigate to Analytics and then Analytics Cloud.
Open the Cloud Analytics URL associated with your instance by using the dots
menu button on the right-hand side of your instance information and selecting
Open URL.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
47
The Oracle Analytics page will open in a new browser window/tab.
On the top right-hand side of the screen, click Create, and then Connection.
Choose Oracle Autonomous Transaction Processing.
Use the following information to configure your connection:
Connection Name: WORKSHOPATP
Client Credentials: Use the Browse button to upload the wallet zip file that
you downloaded. It will automatically extract the cwallet.sso file from this zip
bundle.
Username: WORKSHOPATP
Password: The password that you used when you created the workspace at
the beginning of the workshop.
Service Name: Choose the name of your database followed by the _high
suffix.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
48
Select Save to save your new connection information.
Prepare the dataset
On the top right-hand side of the screen, click Create, and then Data Set.
Select WORKSHOPATP, the connection you created in the previous step.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
49
Click on the WORKSHOPATP schema.
Choose the DEM_PROJECT_HOUR table.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
50
This will display the columns available in the DEM_PROJECT_HOUR table.
Select Add All to select all columns in the table, and then Add to create the Data
Set.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
51
In the 'Preparation Script' screen, make sure the ID column is used as an identifier
by clicking on its name, and then change the Treat As (lower left-hand side of the
screen) setting it to Attribute.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
52
Create a new project by clicking Create Project in the menu ribbon. Sometimes the
Create Project button is not visible when your browser window is not maximised.
You could either maximise the window or toggle off the advice panel, using the
button on the bottom right hand side.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
53
Select to Apply Changes to your Data Set.
Create Self-Service analysis
You will create self-service analytics based on the data within your APEX
application. The advantage of self-service analytics is that you do not need to be
able to write complex SQL to extract the data, and you can quickly change or
enhance an existing analysis.
Imagine you have the question "How do I improve the revenue generated by
billable hours?". This is a big question that would be hard to express as a
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
54
specification for a developer. The best way to work this out is to build up your
knowledge about the employees, projects and the revenue generated as a series of
self-service analyses.
First get some background knowledge: "Which employees work the most hours as
a consultant, and at which company?".
Add fields to your visualization, by dragging them from the left side bar list, onto
the canvas. It is best to multi-select by using the <CTRL> key rather than dragging
one by one as you will get a better automatic visualization. This example requires
NUMBER_OF_HOURS, EMPLOYEE and CUSTOMER.
Change the chart type to Stacked Bar. If your graph does not look like the one in
the example then verify that your settings are
Values (Y-Axis): NUMBER_OF_HOURS
Category (X-Axis): CUSTOMER
Color: EMPLOYEE
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
55
After looking at is data, you have a new question. "Are the employees that work the
most hours also the ones that earn most money for our company?"
This data is not directly available in the data set but can be calculated.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
56
Create a Revenue field. In the right-hand Data sidebar, right click on My
Calculations and select Add Calculation.
Drag the NUMBER_OF_HOURS and HOURLY_RATE fields into the formula space.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
57
Create the following formula:
HOURLY_RATE * NUMBER_OF_HOURS
Name the new field Revenue.
Press Save.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
58
Now duplicate the original chart, by clicking on the menu button on the chart, and
then Edit and Duplicate Visualization.
You will now have 2 charts on your canvas.
Select one of the charts by clicking on it. It will have a blue outline around the chart
to show that this is the active selection.
Replace NUMBER_OF_HOURS with the new Revenue field. You can do this by
dragging-and-dropping the Revenue filed over the NUMBER_OF_HOURS.
Change the aggregation method of Revenue on the same chart.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
59
Click on Revenue in the Data sidebar. In the bottom left of the screen, select the
Values tab by clicking the # symbol.
Change the values as follows (you may have to scroll to find them).
Aggregation Method : Sum
By : Id.
The result is like this:
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
60
What can we learn from these charts?
• Lisa Jones bills a lot of hours to the project JP Corp Project, but these hours
do not generate a large amount of revenue.
• Other employees such as James Numan and Cindy Cochran bill fewer, but
higher value hours.
Now you have the follow-on question "Does a higher hourly rate also mean higher
total earnings per employee?"
Create an additional chart on the same page. Drag Revenue, HOURLY_RATE and
EMPLOYEE to the left-hand edge of one of the existing graphs. You will see a blue
bar appear, to indicate that it is going to insert a new chart rather than overwrite an
existing one.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
61
The new chart should automatically visualize as 'Scatter' if you dragged the 3 fields
at the same time. If not change the type to 'Scatter' and verify that you have the
following settings for the graph.
Values (Y-Axis): REVENUE
Values (X-Axis): HOURLY_RATE
Category (Points): EMPLOYEE
You are going to change the aggregation method for Revenue on your new chart.
Click on Revenue in the Data sidebar. In the bottom left of the screen, select the
Values tab by clicking the # symbol.
Change the values as follows, you may have to scroll to find them. (If your view
does not match the screenshot below, click on your new chart and this should
populate the Data sidebar with the 3 fields)
Aggregation Method : Sum
By : Id
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
62
Click on the HOURLY_RATE in the Data sidebar. In the bottom left of the screen,
select the Values tab by clicking the # symbol.
Change the values as follows (you may have to scroll to find them).
Aggregation Method : Average
By : Id.
The resulting chart should look similar to this.
What have you learned from this new chart?
• There are 3 employees who have a higher average hourly rate, and have a
higher revenue earned by them
This will lead to a follow-on question. "What is the secret of these high earners? Is it
a particular training course or skill?"
This training information is not stored in our APEX Time and Labour application.
This data has been provided to the end user by Human Resources, using an Excel
spreadsheet traininghistory.xlsx. (This is traininghistory.xlsx in the lab zip file).
Click the '+' in the top left-hand side Data side bar.
Select Add Data Set.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
63
On the Add Data Set pop up select Create Data Set.
On the Create Data Set popup use the icon to drag and drop the Excel file,
or browse for the file on your disk.
The file will be displayed for review. It contains the employee first and last names,
and their training status (not started/started/finished). Select Add.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
64
You need to be able to link the new data set from Excel, with the existing data in the
database. The data set in the database has a column containing the employees full
name, whereas the Excel has First and Last names in separate fields.
The solution is to create a concatenation of First and Last name on the new training
Data Set.
Click on the + symbol to add a new preparation step.
You are going to create a new concatenated column.
Name your New Column 'TRAINEE NAME'
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
65
Enter the following in the Calculation Field. Where it suggests auto completions for
the field name, you can accept them.
CONCAT (First Name, CONCAT(SPACE(1), Last Name))
Select Add Step
Apply the change to the Data Set by selecting Apply Script.
Next you will link the two Data Sets. Click on Data Diagram on the bottom of the
screen.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
66
Create a new relationship by hovering on the space between the two datasets, and
clicking the 0. This will open the Connect Sources popup.
Select Add Another Match and choose the two columns that contain the full
employee name. Click Ok.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
67
You will now see this relationship reflected on the diagram.
Select Save and just leave it with the default name of 'Untitled'. You will set the
correct name later in the lab.
Return to your Visualization charts by selecting Visualize in the menu bar.
Drag the Status field of the traininghistory data source onto the Shape of the
scatter chart.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
68
This will change the shape of the scatter data points to reflect the training status.
This shows that
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
69
• The highest earners have all completed this particular training. It may be
worthwhile prioritizing completing this training for all employees.
Select Save As and name the project Labour.
Embed the OAC Data Visualization project into APEX
Next you will integrate your ' Labour' visualization project into the APEX
application.
First collect the information required to connect to your OAC Project from another
application.
Using the Menu button on the top right of the chart canvas select Developer.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
70
Select the Embed tab.
Copy the codes provided in Embedding Script to Include and Default as you will
need these later.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
71
For security reasons, you are not allowed to add external content to reports or
embed your reports in other applications unless your administrator considers it
safe to do so. Only administrators can add safe domains to the whitelist.
Whitelisting allows or approves access to specific content.
Access the OAC console by selecting the menu button in the top-left of your page
and then Console.
Select Safe Domains
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
72
To locate the correct URL to add to this page, open a browser to the Service
Console for your Autonomous Database.
Select the Development link in the left-hand menu. In the region RESTful Services
and SODA copy this link. You need to remove the /ords at the end of the link
before adding it to your list of Safe Domains. For example: If your link is
https://faw1dalxtmqfgcp-melapex.adb.eu-frankfurt-
1.oraclecloudapps.com/ords/
Then the URL to whitelist will be
https://faw1dalxtmqfgcp-melapex.adb.eu-frankfurt-1.oraclecloudapps.com
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
73
Use this amended URL as Domain Name on the Safe Domains page.
For this lab, tick all the boxes for your domain, in a production situation you should
deselect any permissions that are not required.
The changes on this page are automatically saved, so use the back arrow to exit
this screen.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
74
Open the APEX login screen. If you do not have a direct link or an open browser
window to this page you can access it by returning to the Service Console of your
Autonomous Database, select Development, and then Apex.
Login to APEX using:
Workspace name: WORKSHOPATP
User name: WORKSHOPATP
Password: Password you selected when creating the workspace.
Edit your Time and Labour application.
Edit the page Customer Form.
Create a region on this page to render the Oracle Analytics Cloud. Right clicking on
Customer Form in the rendering left-hand side bar and selecting Create Region.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
75
Complete the properties for your new region using:
Title: OAC Region
Type: Static Content
Source: this code is available in the lab zip file as lab500-oac-region-
source.txt
<div style="height: 600px; width: 100%;">
<oracle-dv project-path="{{projectPath}}" filters="{{filters}}">
</oracle-dv>
</div>
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
76
Select the top level of the page Page 7: Customer Form. In the properties on the
right-hand side of the page, scroll to JavaScript.
File URLS: This is based on the link Embedding Script to Include that you
saved from OAC. The URL is specific to your environment. Copy and Paste
only the URL part of the OAC link, and change <embedding mode> to
standalone
Execute when Page Loads: This is based on lab500-java-page-load.txt in
the lab zip file. Replace the 2 occurrences of [email protected]
with the username from the Default link you saved in OAC.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
77
Save your changes to this page and then go back to the overview page for your by
clicking on the 'Application' link on the top left-hand side.
Go back to the Application page overview. Change the page view to report by
selecting the View Report button next to the Actions drop down.
Run the page Customer Report.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
78
Click on the Edit icon for one of the customers.
The page now includes your OAC visualization, filtered by the Customer you have
selected.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
79
You have now completed Lab 500.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
80
Want to learn more about APEX? APEX Collateral http://apex.oracle.com
Tutorials : https://apex.oracle.com/en/learn/tutorials
Community : http://apex.oracle.com/community
External Site + Slack: http://apex.world
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
81
Appendix A – Provisioning an
Oracle Analytics Cloud Instance If your Oracle Cloud account started before 14 February 2020 (USA) or 2nd March
2020 (EMEA) you have the option to deploy Oracle Analytics Cloud Instances using
a different method. This is documented below for completeness, but it is expected
that people running the workshop to use the Oracle Analytics Cloud on Oracle
Cloud Infrastructure Gen 2 which is documented in the main body of the document.
Your Oracle Cloud Free Tier account will use the Oracle Cloud Free Trial credits
while this instance is provisioned, as Oracle Analytics Cloud is not part of the
Always Free cloud services.
Provisioning an Oracle Analytics Cloud instance can take over 40 minutes. If you
plan to run Lab 500 during the classroom session, then you can provision the
instance now and have it ready for use later.
Return to the Oracle Cloud Infrastructure console, click on the menu icon on the
left. Verify that you are signed in as a Single Sign On (idcs) user by selecting the
Profile icon in the top right hand side of your screen. If your username is shown as:
<idcs server name> / <your username> then you are connected as a Single Sign
On user.
If not, please logout and select to authenticate using Single Sign On.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
82
Navigate to Platform Service and then Analytics.
Note: You must be connected as a Single Sign On (idcs) user to a tenancy
which has available cloud credits to see this menu item. Local OCI users are
not able to do this.
This will open a new browser tab/window. Select Create Instance.
Complete the form using the following information:
Instance Name: WORKSHOPATP
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
83
License Type: "Subscribe to a new Analytics Cloud software license and the
Analytics Cloud." (You will use this service as part of the free Oracle Cloud
trial that you requested for this workshop)
Region: No preference
Edition: Oracle Analytics Cloud - Professional (important)
Feature Set: Professional Edition Feature Set (important)
Number of OCPUs: 1 - Non Production
Select Next.
On the Confirmation screen select Create.
You can now proceed onto running the labs.
Oracle Solution Center
ADB for Apex Developers Hands on Lab Guide – Part 2
Oracle Solution Center
Version 1.2
84
Oracle Corporation, World Headquarters Worldwide Inquiries
500 Oracle Parkway Phone: +1.650.506.7000
Redwood Shores, CA 94065, USA Fax: +1.650.506.7200
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and
the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.
C O N N E C T W I T H U S
blogs.oracle.com/oracle
facebook.com/oracle
twitter.com/oracle
oracle.com