Creating A Simple Autonomous Database Application in Oracle APEX
Creating A Simple Autonomous Database Application in Oracle APEX
in Oracle APEX
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
1
Tutorial: Creating a Simple Database Application in Oracle APEX
Topic Details
Overview In this tutorial, you will create a simple database application in Oracle APEX
using App Builder.
Key Concepts • Create an application using the Application Wizard
• Create additional pages using the Page Wizard
• Use existing sequences to populate primary key columns
• Create Lists of Values to populate foreign key columns.
• Create Master Detail Forms
• Upload an image file to display on a page in the application
Difficulty Intermediate
Duration Approximately 90 minutes
Note: Learners will require access to an active APEX account with tables and
data uploaded from the SQL schema script file (which can be accessed from
Course Resources of either database course).
This tutorial was built using APEX 22.2
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
2
Part 1: Introduction and Getting Started
This tutorial will demonstrate how to create a database application using the App Builder
component of Oracle Application Express (APEX) on a Cloud Autonomous Database.
The application created in this tutorial will allow end-users to add, modify and delete data in the
existing Jobs, Employees and Departments tables without the need to run SQL queries.
2. By default, APEX is in “Dark Mode”. The screenshots in this lab are displayed in “Light Mode”.
You can select your chosen mode by clicking your workspace name from the top right of
APEX home page and clicking your choice.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
3
Step 2: Accessing Application Builder
1. In the home page of APEX, click the App Builder icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
4
Step 4: Name the Application
Follow the steps below to continue creating the application:
2. Select an icon and its color to use for your application, then click Set Application Icon. (You
can also upload an image to use as the app icon by dragging an image file from your local
machine to the “Upload your own icon” area.) Click Save Icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
5
3. Scroll down to confirm the Settings options:
Application ID: Do not change the application number. APEX creates an application number
by default, and it is recommended that you do not change this number.
In this step, we will add a page that will display the data in the jobs table.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
6
2. Select Interactive Report.
Table or View: Click the list icon, find the Jobs table, and click it.
Click Set Icon and select the icon you want to use for the page. (The example below uses the
fa-briefcase icon).
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
7
4. The Jobs page should show in your application.
6. You will see your application and the pages it contains. If your pages are displayed as a list,
click the view icons button. (Note: The “Application” number may differ)
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
8
Step 6: Run and Test Application
1. Click the Run Application icon. Your application will open in a new browser window (or tab).
Login using your APEX username and password.
2. Once the app is displayed in the browser, click the Navigation Menu icon to expand the
navigation pane, then select the Jobs page from the navigation pane on the left or by clicking
the page icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
9
3. The data in the jobs table will be displayed.
4. Close the browser tab (or window) showing the running application.
1. If your application home page is not displayed, click the App Builder icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
10
3. From the application home page, click the Create Page > button to start the Page Wizard.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
11
2. Enter the following properties for the Page Definition:
Page Number: 3
Include Form Page: Move the slider to make it green (on position)
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
12
Step 3: Select Data Source
1. Scroll down to the Data Source properties and enter the following properties:
Table / View Name: Click the list icon and select the EMPLOYEES table
You can select a page icon by clicking the Select Icon button
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
13
Click the Next button.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
14
2. The Employees Report will open in the Page Designer view. Click the Application Number to
return to the application’s home page. (Note: Your application number may look different.)
3. You will see that two new pages have been added to your app, Employees report and Update
Employees. Click the Run Application icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
15
4. Login with your APEX username and password if prompted, click Employees Report from
the Navigation Menu, and you will see all employees displayed. Click the edit icon in a row of
data.
5. The Update Employees Form is displayed, which allows employee details to be edited. Do not
attempt to modify or insert records at this time. Close the Update Employee form by either
clicking one of the pages in the Navigation Menu on the left of the window or scroll down the
Update Employee form and click the Cancel button.
The employees table has three foreign key columns. In order to successfully insert or update a
record, valid values must be used for these columns that already exist in the parent tables. Using
values that are not present in the parent tables will result in an integrity constraint error when
attempting to insert or update a record.
By default, the Job Id, Manager Id, and Department Id fields are of type Select List, which use an
automatically created List of Values to allow the user to select existing values from the parent
table.
The Manager Id, Select List, picks up all employees regardless of whether they are manager or not,
and only displays the first name.
To address this, we can create a List of Values (LOVs) manually, that forces the user to select only
valid values, employees that are managers. We can also display both first and last name.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
16
Step 1: Open the Update Employees Page for Editing
1. From the application home page, Click page 4 – Update Employees.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
17
2. In the Other Components section, click Lists of Values.
3. To create an LOV manually, click the Create button. (Note: The 3 existing LOVs that were
automatically created.)
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
18
5. Enter the following:
Name: get_managers
Type: Dynamic
Click Next.
6. The SQL statement for this LOV has two functions to complete. Firstly, we want to display
both the manager first name and last name. As these are two different columns in the table,
we need to use the concatenation operator (two “pipe” symbols || ) to display the manager
full name as if it were a single column.
We also need to add a WHERE clause as, only employees with a job id of AD_PRES, AD_VP or
employees with the text _MAN or _MGR in their job_id can be managers.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
19
7. Once the statement is entered, click the Validation icon (a tick inside a circle). Once you
receive a validation successful message, click Next.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
20
9. The Lists of Values will be displayed on the Shared Component’s LOV page. Click the
Application Number to return to the application home page.
Step 3: Use the Shared List of Values in the Update Employees Page
From the application home page, click page 4 – Update Employees to open the page in Page
Designer.
1. From the Rendering tab, select P4_MANAGER_ID by left mouse clicking it. (Note: If the items
are not listed, you may need to expand Components, Content Body and Region Body).
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
21
2. Continuing in the Page Item area, scroll down to see the List of Values settings. For Type,
select Shared Component and for List of Values, select GET_MANAGERS. Click Save.
3. Run the application to test. If you have coded your SQL statement correctly, the LOV for
Manager Name should show only the seven employees that can be managers. (Note: Do not
attempt to insert a new record at this time.)
If you tried to insert a new employee on the Update Employee page, you would receive an error
message. The employee_id item is hidden by default, so the user cannot enter a value for the
primary key of the table. One solution would be to edit the page and change the employee_id
item’s type from Hidden to Number Field, and users could then enter a value for the
employee_id.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
22
It is, however, unrealistic to expect end users to know what value to use for the primary key,
especially if the table is large and has many rows.
We can create a process that will use a sequence, employees_seq (which was created in your
schema when you ran the script to create and populate the tables) to automatically add values for
the employee_id column in the table.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
23
Step 2: Enter Code for the Process
1. Enter the following for Process. In the Identification area, enter:
Name: get_pk
In the Source area, set Language to PL/SQL, then click the Code editor icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
24
3. Once the statement is entered, click the Validation icon (a tick inside a circle), and if you
receive a validation successful message, click OK.
4. The new get_pk process must run before the other process to ensure that employee_id
has a value before the insert is processed.
5. In the processes tab, left mouse click and drag the new get_pk process so that it is above the
Process form Update Employees process. Click Save.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
25
Step 3: Run and Test
1. Run the application to test. Open the Employees Report and click the Create button. Enter
values for a new employee and click Create.
2. You should see the new employee included in the Employees Report page.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
26
Part 5: Add a New Page to View Departments and their Employees
In this section, we will add a Master Detail form, which will display departments, and the employees
that are assigned to each department on a separate page. The page will also allow the user to
update, add and delete departments.
Master Detail refers to the relationship between the two tables. The employees table has a foreign
key relationship with the departments table, so the departments table is known as the master
table, and employees as the detail table.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
27
3. Select Drill Down, click Next.
Page Number: 5
Name: Departments
Table / View Name: Click the list icon and select DEPARTMENTS
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
28
Step 2: Apply Navigation Menu Settings
1. Scroll down to the Navigation properties and check the following properties are selected:
You can select a page icon by clicking the Select Icon button.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
29
Step 3: Select Primary Key
1. Check the following properties for Primary Key:
Click Next.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
30
Step 4: Select Detail Table and Primary Key
1. Check the following properties for Detail Page Definition:
Page Number: 6
Click Next.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
31
2. Check the following Detail properties:
1. From the Rendering tab, select P6_MANAGER_ID by left mouse clicking it. (If the items are
not listed, you may need to expand Components, Body, Form on Departments and Region
Body).
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
32
2. In the Page Item area, change the Label to Manager Name.
3. In the Page Item area, scroll down to see the List of Values settings. For Type, select Shared
Component, for List of Values, select GET_MANAGERS (which we created earlier). Click Save.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
33
1. From the rendering tab, select P6_LOCATION_ID by left mouse clicking it. (If the items are
not listed, you may need to expand Components, Body, Form on Departments, Region
Body).
2. In the Page Item area, scroll down to see the List of Values settings. For Type, select SQL
Query and click the icon to open the code editor:
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
34
4. Click the Validate button. Once successful, click OK.
1. From the rendering tab, scroll down to Department Employees (it is near the bottom of the
rendering tab) and left click to select the form. In the Region tab, change Type from
Interactive Grid to Interactive Report. Click Save.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
35
2. Run your application to test. Do not create a new department at this time.
In this step, we will create a new process to automatically generate primary key values using an
existing sequence when creating a new department the same way we did earlier for the
employee_id primary key.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
36
Step 2: Enter Code for the Process
1. Enter the following for Identification:
Name: get_dept_pk
2. Ensure the following for Source details. Then click the icon to open the code editor.
5. The new get_dept_pk process must run before the other process to ensure that
department_id has a value before the insert is processed.
In the processes tab, left mouse click and drag the new get_dept_pk process so that it is
above the Process form Form on DEPARTMENTS.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
38
2. Enter values for a new department, then click Create.
3. The new department should be displayed in the Department Report, and a Row created
message will be displayed.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
39
Step 1: Change the Navigation Menu Icons
1. From the Employee Database Application home page, click Shared Components.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
40
4. Click the Edit icon for Departments.
6. Scroll down through the icons and left click the fa-building icon.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
41
7. Click Apply Changes.
8. Follow the same process to change any other icons as required. The example below uses:
Jobs: fa-briefcase
Departments: fa-building-o
Run the application to test. The new icons will now be shown in the Navigation Menu.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
42
Step 2: Add Navigation Tiles to the Home Page
1. From the Employee Database Application home page, click Shared Components.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
43
4. Click Create Entry.
Image/Class: fa-user
Page: 3
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
44
6. Enter the following properties:
Image/Class: fa-building-o
Page: 5
7. Return to the Employee Database Application home page and run the application to test.
There should now be 3 navigation tiles showing.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
45
Part 8: Add an Image to the Home Page
First find an image you want to use on the home page, and save locally on your PC, noting its
location. Make sure the image is not too large, as we want it to fit on screen without the user having
to scroll across the page. The size should be no more than 450 pixels wide, and 200 pixels high.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
46
3. Click Create File.
4. Locate the image you want to use on your local machine and drag and drop it into the
Content area. Click Create.
5. Your file will be created. Copy the reference into a text document (click the Copy icon) as this
is how your application will locate the file from the home page. Click Save Changes.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
47
Step 2: Add a Region to the Home Page Content Body
1. Navigate back to the Employee Database Application home page, click page 1 – Home.
2. In the Layout section, scroll down to locate the BODY section. Locate and click the Regions
tab. In the Regions section, scroll down to see the Static Content region. Drag the Static
Content region into the content BODY above the existing entry for Page Navigation.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
48
3. The new region will be shown directly below the BODY section. In the Region tab, enter the
following properties:
4. Still in the Region tab, scroll down to the Appearance section. Ensure the following
properties:
Template: Image
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
49
Step 3: Test the Application
1. Run the application to test. Your home page should now display your image, similar to the
example below.
Copyright © 2024, Oracle and/or its affiliates. Oracle®, Java, MySQL and NetSuite are registered trademarks of Oracle and/or its affiliates. Other
names may be trademarks of their respective owners.
50