filmov
tv
How to insert data that comes from JSON into a table in Oracle APEX

Показать описание
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!How to insert data that comes from JSON into a table in Oracle APEX
I have an application in Oracle Apex that needs to consume data from a JSON that comes through a webhook, and insert it into my table.
The data is coming in the following structure:
{
"event_type": "WEBHOOK.MARKED_OPPORTUNITY",
"entity_type": "CONTACT",
"event_identifier": "my-event-identifier",
"timestamp": "2018-03-13T14:09:02.724-03:00",
"event_timestamp": "2018-03-13T14:07:04.254-03:00",
"contact": {
"uuid": "c2f3d2b3-7250-4d27-97f4-eef38be32f7f",
"email": "[email protected]",
"name": "Contact Name",
"job_title": "Developer",
"bio": "This is my bio",
"personal_phone": "48 30252598",
"mobile_phone": "48 30252598",
"city": "Florianópolis",
"facebook": "Contact Facebook",
"linkedin": "Contact Linkedin",
"twitter": "Contact Twitter",
"tags": [
"tag 1",
"tag 2"
],
"cf_custom_field_example": [
"Option1",
"Option2"
],
"company": {
"name": "Company Example 0"
},
"funnel": {
"name": "default",
"lifecycle_stage": "Lead",
"opportunity": false,
"contact_owner_email": "[email protected]",
"interest": 20,
"fit": 0,
"origin": "Orgânico"
}
}
}
{
"event_type": "WEBHOOK.MARKED_OPPORTUNITY",
"entity_type": "CONTACT",
"event_identifier": "my-event-identifier",
"timestamp": "2018-03-13T14:09:02.724-03:00",
"event_timestamp": "2018-03-13T14:07:04.254-03:00",
"contact": {
"uuid": "c2f3d2b3-7250-4d27-97f4-eef38be32f7f",
"email": "[email protected]",
"name": "Contact Name",
"job_title": "Developer",
"bio": "This is my bio",
"personal_phone": "48 30252598",
"mobile_phone": "48 30252598",
"city": "Florianópolis",
"facebook": "Contact Facebook",
"linkedin": "Contact Linkedin",
"twitter": "Contact Twitter",
"tags": [
"tag 1",
"tag 2"
],
"cf_custom_field_example": [
"Option1",
"Option2"
],
"company": {
"name": "Company Example 0"
},
"funnel": {
"name": "default",
"lifecycle_stage": "Lead",
"opportunity": false,
"contact_owner_email": "[email protected]",
"interest": 20,
"fit": 0,
"origin": "Orgânico"
}
}
}
[email protected]
[email protected]
My question is how do I insert some of this data into my table when I trigger POST?
I'm trying this PL/SQL on my RESTful data services POST method
DECLARE
new_id INTEGER;
current_date DATE;
blob_body BLOB := :body;
clob_variable CLOB := CONVERT_TO_CLOB(blob_body);
v_name VARCHAR2(100);
v_email VARCHAR2(100);
BEGIN
SELECT SYSDATE INTO current_date FROM dual;
DECLARE
v_json_obj JSON_OBJECT_T;
BEGIN
v_json_obj := JSON_OBJECT_T.parse(clob_variable);
END;
INSERT INTO LEADS (ID, NOME, EMAIL)
VALUES (121212, v_name, v_email)
RETURNING ID INTO new_id;
:status_code := 201;
:forward_location := '../employees/' || new_id;
EXCEPTION
WHEN VALUE_ERROR THEN
:errmsg := 'Wrong value.';
:status_code := 400;
WHEN OTHERS THEN
:status_code := 400;
:errmsg := SQLERRM;
END;
DECLARE
new_id INTEGER;
current_date DATE;
blob_body BLOB := Source of the question:
Question and source license information: