Here's the case we'll work on using the following example:
The case is : How to Fetch specific data from EMP_TABLE using API ?
The Fix: Using GET method
Before You Begin: In contrast to GET methods, all of POST,PUT and DELETE methods require third party editor to run .
There are many applications for this purpose, you can install any of them using Google Chrome web store .
YARC may be the simplest one to use , you can download it from here .
The case is : How to Fetch specific data from EMP_TABLE using API ?
The Fix: Using GET method
Before You Begin: In contrast to GET methods, all of POST,PUT and DELETE methods require third party editor to run .
There are many applications for this purpose, you can install any of them using Google Chrome web store .
YARC may be the simplest one to use , you can download it from here .
- Using PLSQL copy the following code:
BEGIN
-----------------
ORDS.DEFINE_MODULE(P_Module_Name => 'emp',
P_Base_Path => 'emp_data',
P_Items_Per_Page => 0);
-----------------
ORDS.DEFINE_TEMPLATE(P_Module_Name => 'emp',
P_Pattern => 'dml');
-----------------
ORDS.DEFINE_HANDLER(P_Module_Name => 'emp',
P_Pattern => 'dml',
P_Method => 'POST',
P_Source_Type => 'plsql/block',
P_Source => 'BEGIN
INSERT INTO EMP_TABLE(Id, Name)
VALUES (:Id, :Name);
COMMIT;
-----------
:P_Status := SQLERRM;
-----------
END;',
p_mimes_allowed => '',
P_Items_Per_Page => 0);
-----------------
ORDS.DEFINE_PARAMETER(P_Module_Name => 'emp',
P_Pattern => 'dml',
P_Method => 'POST',
p_name => 'P_Status',
p_bind_variable_name => 'P_Status',
p_source_type => 'RESPONSE',
p_param_type => 'STRING',
p_access_method => 'OUT');
COMMIT;
-----------------
END;
In This POST Request:
- Data INSERTED into EMP_TABLE
- P_Status Parameter defined to return message after inserting data
To run POST request :
- Click YARC extension from google chrome
- In the URL add: http://localhost:8080/ords/trest/emp_data/dml
- Choose from the list : POST
- In Payload,add the new data: {"Id":1, "Name":"Omar"}
you should get reply of 200 and the following message:
{
"P_Status": "ORA-0000: normal, successful completion"
}
In the next post, we'll create PUT request.
Mango Habanero - MapyRO
ReplyDeleteMango 제천 출장안마 Habanero - MapyRO - 경상북도 출장안마 Best 경상북도 출장안마 Mango 성남 출장안마 Habanero Hot Sauce 제주 출장안마 in December 2021