I’ve found this APEX Tutorial playlist on Youtube:
So you get a quick introduction to this great development tool and environment.
This site is about my experience as Project Manager. I'd like to provide useful tips and tricks I'm using every day. Opinions are my own
I’ve found this APEX Tutorial playlist on Youtube:
So you get a quick introduction to this great development tool and environment.
Earlier in 2015, I’ve read an interesting article from HBR on how to prevent one to click too fast on the send button. It happens to me quite a few times in the past where I would have preferred to re-write/correct some emails before sending.
So I’ve set this rule in my outbox folder and it helped me many times. I would recommend to set this up after any Outlook installation.
Thanks to John Jacob who helped me understand how to call OAuth2 from Postman.
With APEX REST API, any operation is exposed internally or externally if not properly secured. APEX REST API could be secured using OAuth2 however if used from Clover ETL it requires extra steps.
This article explains how to get the OAuth token and use it from Clover ETL to get and post requests to Oracle APEX REST API.

To call a secured REST API (Oracle APEX in my case) by OAuth, an initial token call should be made, the token extracted and then the next Http requests could be made.
Here are the few components to perform these:
function integer transform() {
$out.0.grant_type = “client_credentials”;
return ALL;
}
This provides the grant type method used by OAuth. The metadata that outputs from this is simply one string grant_type.


function integer transform() {
$out.0.content = $in.1.content;
return ALL;
}
The metadata that outputs from this component is simply one string content.


<Mappings>
<Mapping element=“json_object” outPort=“0”
xmlFields=“{}access_token”
cloverFields=“access_token”>
</Mapping>
</Mappings>
Again, the output metadata is simple a string access_token.

function integer transform() {
map[string,string] headers;
headers[“Authorization”] = “Bearer ” + $in.0.access_token;
$out.0.additionalHTTPHeaders = headers;
return ALL;
}
The remaining setup will depend on your requirements.
In APEX, it’s easy to protect the REST API from the user interface. You can define a privilege to protect your REST API resources as:

Select at least one role that will be used later in the security setup.
Once this is defined, your module will appear with a green checkmark:

To get the client ID and secret, you need few extra steps described in this article in the SQL Commands part of APEX:
OAUTH.create_client(
p_name => ‘Emp Client’,
p_grant_type => ‘client_credentials’,
p_owner => ‘My Company Limited’,
p_description => ‘A client for Emp management’,
p_support_email => ‘tim@example.com’,
p_privilege_names => ’emp_priv’
);
OAUTH.grant_client_role(
p_client_name => ‘Emp Client’,
p_role_name => ’emp_role’
);
SELECT id, name, client_id, client_secret
FROM user_ords_clients;
Special thanks to Alexandre Lacour who helped me discovered this nice feature from Clover and put me in the right direction.
With APEX, data loading is quite easy through various functions however in case you must upload large quantities frequently or if you’re limited to upload some quantities, it’s becoming frustrating to split your file in multiple chunks.
Through REST API, Clover ETL (now renamed Clover DX) could upload data through JSON chunks.
In the following article, I’ll show how to setup the Clover components to connect and upload to APEX Rest API. I’ll show an example of REST API as well.

Once you’ve installed Clover ETL, you can create a new project and setup a new graph. Here are the 2 components you need to connect to APEX:
The metadata on the arrow is defined as:

On the JSONWriter, you have to setup the following attributes:

{“items”:[{“id”:”ABC789″,”region”:”EUROPE”},{“id”:”DEF789″,”region”:”ASIA”}]}
In the source tab of the mapping attribute, you should enter:
<?xml version=“1.0” encoding=“UTF-8”?>
<root xmlns:clover=“http://www.cloveretl.com/ns/xmlmapping”>
<clover:collection clover:name=“items” clover:inPort=“0”>
<element2>
<clover:element clover:name=“id”>$0.Id</clover:element>
<clover:element clover:name=“region”>$0.Sales_Region</clover:element>
</element2>
</clover:collection>
</root>
On the HTTPConnector, you have to setup the following attributes:

function integer transform() {
$out.0.requestContent = $in.0.json_text;
return ALL;
}
This tutorial is based on APEX version 18.2 and is using the ORDS RESTful Services (Under SQL Workshop).
Aim is to create a POST handler definition as:

Here is the step by step process:
DECLARE
l_blob blob := :body;
c_json clob;
BEGIN
c_json := clobfromblob(l_blob);
insert into MY_DUMMY_TABLE (ID, REGION)
select identifier, region
from JSON_TABLE(c_json, ‘$.items[*]’
COLUMNS (identifier NUMBER PATH ‘$.id’,
region VARCHAR2(20) PATH ‘$.region’
)
);
:output := 201;
EXCEPTION
when others then
:output := 400;
END;
EDIT (March 2019): With APEX 19.1, there is a new package APEX_DATA_PARSER that allows to perform the above – Check this article out: https://blogs.oracle.com/apex/super-easy-csv-xlsx-json-or-xml-parsing-about-the-apex_data_parser-package
This method takes the body of the POST request as BLOB, transforms this into CLOB. Then it inserts the data into a dummy table from a SELECT statement. This statement is using a new database feature that reads CLOB and transforms JSON text into table.
More information on JSON_TABLE
Source code for clobfromblob

You can then test this REST API from Postman before trying from Clover.
In case when creating the JSON text in the JSONWriter component you get some memory consumption error, you can change the ETL Runtime Preferences at Window > Preferences as follow:

Thanks for joining me!
Good company in a journey makes the way seem shorter. — Izaak Walton
