
#Pl sql json query Patch
To test out the result, I sent a POST and a PATCH request to my local ORDS server with the URL After my first attempts were failing to work, I learned from colleagues that ORDS is very exacting when matching the URL for the defined template handlers. The json_object_t object’s stringify() function prints out the contents of the JSON data structure using the right combination of curly braces, colons, quotes, and brackets as needed to produce the expected text representation of the data.

Then we use the venerable htp.p() procedure to write the “stringified” version of the JSON object out to the response. In order to write out the JSON response, we start by using owa_util.mime_header() to add the appropriate HTTP response header that signals to the caller that the response is a JSON document. In the two example handlers above, notice that I’m simply setting one additional JSON property named method-used-was so you can see a difference between sending the sample payload using the POST or PATCH verb.
#Pl sql json query code
The handler’s PL/SQL code can then perform any post-processing if necessary. When the procedure call to generic_service() returns, the l_response variable contains the JSON object returned in the p_response out parameter. L_response.put('method-used-was','patch') L_response.put('method-used-was','post') json-in-json-out method before returning.

Show example of modifying the response from the invoked Owa_util.mime_header ('application/json', true) Generic_service(p_request => json_object_t(:body), In my head, what made the most sense to represent a PL/SQL procedure that accepted a JSON request and returned a JSON response was a procedure specification like this: The Oracle reference docs on PL/SQL JSON datatypes also came in handy while doing this.

After reading another of Tim’s articles RESTful Web Services Handling Complex JSON Payloads, I set out to try my own example. However, to make sure I was understanding all the moving parts, I set myself the task of creating a service that could process an arbitrary JSON document as the request and return back an arbitrary JSON document in response (possibly created programmatically or by doing a JSON SQL query or some combination of the two). In many cases, this lets you focus on your core PL/SQL logic without having to work directly with JSON. I started by experimenting with ORDS’ support for automatic handling of different built-in datatypes to and from JSON. As I’ve been getting up to speed with ORDS REST services over the last couple weeks, Tim Hall’s Oracle-Base tutorial about REST services basics proved very helpful.
