You are on page 1of 16

Practice: Managing

Application Data
Practice 1: Manage Application Data

Overview

Oracle APEX allows you to build robust, feature-rich applications against remote, web, and REST
data sources. In this lab, you log in to a remote database, create a database table, and then
register a schema with RESTful Services. You will then create a new application and then
consume the REST Data Source we created. Then, you will synchronize the data from REST
Data Source to the Local Database table using REST Data Synchronization.

Enable Remote Database Schema to Oracle REST Data Services

Before starting this lab, you need to provision a new APEX instance or Workspace.

In this hands-on lab, you will log in to a new, remote APEX workspace, create a table, and then
register schema with ORDS.

1. Log in to the new workspace you created.

2. Under SQL Workshop, select SQL Commands.

Copyright © 2023, Oracle and/or its affiliates.

360 Practice: Managing Application Data


3. Now, copy the following statements and execute them one by one:
CREATE TABLE "EMP_1"
("EMPNO" NUMBER GENERATED BY DEFAULT ON NULL
AS IDENTITY MINVALUE 1 MAXVALUE 9999999999999999999999999999
INCREMENT BY 1 START WITH 8000 CACHE 20 NOORDER NOCYCLE NOKEEP
NOT NULL ENABLE,
"EMP_NAME" VARCHAR2(10),
"MGR" NUMBER(4,0),
CONSTRAINT "EMP_1_PK" PRIMARY KEY ("EMPNO"))
insert into emp_1(empno, emp_name, mgr) values (10, 'JOHN', 30);
insert into emp_1(empno, emp_name, mgr) values (20, 'CLARA',30);
insert into emp_1(empno, emp_name, mgr) values (30, 'JANE', 40);
insert into emp_1(empno, emp_name, mgr) values (40, 'MATT', null);

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 361


4. Select RESTful Services under SQL Workshop.

5. Click the Register Schema with ORDS button.

6. In the next window, leave the attributes to default and then click Save Schema
Attributes.

Copyright © 2023, Oracle and/or its affiliates.

362 Practice: Managing Application Data


7. Now, click Enabled Objects in the left Navigation Menu and then select Create AutoREST
Object button.

8. Under AutoREST Enable Object, select the following and click Create.

• Set Object Type to TABLE.

• Select EMP_1 for Object

• Copy the Full URL and paste it in your Note pad.

Then Click Apply.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 363


9. Now, please change the Copied URL and replace ords with pls/apex and Workspace
Name with your Actual Workspace name as shown below.
Copied URL: https://apex.oracle.com/ords/wksp_apexhandsonlabs/emp34/
Updated URL: https://apex.oracle.com/pls/apex/apex_handson_labs/emp_1/

Create an Application and Integrate Application Data from REST Data Source

In this lab, you create a New Application and then consume the REST Data Source we created
in the previous task. Then, you will synchronize the Data from REST Data Source to the Local
Database table using REST Data Synchronization.

1. Log in to the first workspace, where we have already created multiple applications.

2. Select App Builder under Workspace Home Page.

Copyright © 2023, Oracle and/or its affiliates.

364 Practice: Managing Application Data


3. Now click the Create button to create a new application.

4. Under Create an Application, select New Application.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 365


5. Enter the following and click Create Application.
• For Name - Enter Leave Request Approval.

6. Navigate to Shared Components and then Select REST Data Sources.

Copyright © 2023, Oracle and/or its affiliates.

366 Practice: Managing Application Data


7. Under REST Data Sources, click the Create button.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 367


8. Under Create REST Data Source - Method, leave the settings to default and select Next.

9. Under Create REST Data Source, enter the following and click Next.
• For REST Data Source Type - select Oracle REST Data Services.
• For Name - Enter Employee Details API.
• For URL Endpoint - Enter the URI we copied in Task 1.

Copyright © 2023, Oracle and/or its affiliates.

368 Practice: Managing Application Data


10. Now, under Create REST Data Source - Remote Server, leave all fields to Default and
then click Next.

11. For Authentication, set Authentication Required to No. Click Discover.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 369


12. Click the Create REST Data Source button.

Synchronize Data from REST Data Sources to a Local Table

In this lab, you will synchronize data from the REST Data source you created in Task 2 to a
Local table.

The Data Synchronization feature enables developers to automatically sync the contents of a
local table with the data from an external REST service. Basically, APEX invokes the REST Service
defined in the REST Data Source, downloads all data, and synchronizes it to a local table.

1. Now that you have created a REST Data Source, Under REST Data Sources, select No
under the Synchronized column for Employee Details API.

Copyright © 2023, Oracle and/or its affiliates.

370 Practice: Managing Application Data


2. Synchronization is not configured yet. In this step, you provide the name of a new table or
an existing table. In this example, select New Table for Synchronize To and enter EMP_2 for
Table Name. Then, click Save.

3. The synchronization table is not created yet. You can view the SQL that is used to create
the table. Click Show SQL.

4. Under Table Status, click Create Table. The table EMP_2 is now ready for synchronization.
Notice the message The synchronization table exists and matches the Data Profile.

5. You will define a synchronization schedule now. In the Synchronization Schedule field,
you can use the Database Scheduler calendaring syntax to define repeating
synchronization schedules, such as "every Tuesday and Friday at 4:00 p.m." or "the second
Wednesday of every month." This calendaring syntax can be provided manually. Click the
Schedule Builder button next to Synchronization Schedule.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 371


6. The Interval Builder dialog box is displayed. In this example, for Frequency, select Minutely
and enter 10 for Interval. Then, click Set Execution Interval.

7. You are now ready to test the data synchronization. Click Save and Run.

8. You can see that data synchronization is triggered.

Copyright © 2023, Oracle and/or its affiliates.

372 Practice: Managing Application Data


You now know how to log in to a remote database, create a database table, and then register a
schema with RESTful Services. Also, how to create a new application, consume the REST
Data Source and synchronize the data from a REST Data Source to the Local Database table
using REST Data Synchronization.

You may now proceed to the next lab.

Copyright © 2023, Oracle and/or its affiliates.

Practice: Managing Application Data 373


Copyright © 2023, Oracle and/or its affiliates.

374 Practice: Managing Application Data

You might also like