venerdì 13 maggio 2016

Oracle Rest Data Service & Oracle Cloud (Second Part): How to INSERT (POST) data with REST

In the [FIRST] part you have learned how to create a REST Data Service in Oracle Database (in Cloud)

We have create a SELECT (GET), now we will see how to create an INSERT (POST).

You can use the "auto rest" (more info here) but with this you can do only simple insert, with primary key and only a "select * ..." if you would like to specialized your INSERT (or UPDATE or DELETE) you must do what I will explain in this post.

We will create a Data Service that will insert a row in the "emp" table of the HR user:


This is the configuration:
Insert in the Source field your preferred insert:

begin  
    insert into emp (empno,ename,job,hiredate,sal,deptno) values   
    (:empno,:ename,:job,:hiredate,:sal,:deptno);  
 end; 

This is an example, you can write every kind of complex insert.


 Now you can test it, I suggest to use something like "Postman":

use your url in the POST field:
https://yourIP/ords/pdb1/mariniws/hr/emp/

Set in the Headers tab:
Content-Type: application/json



Select the Body tab and put here the data to send:

 {  
  "empno":1234,  
  "ename":"Marini",  
  "job":"PRESIDENT",  
  "hiredate":"2003-02-01T08:00:00Z",  
  "sal":5000,  
  "deptno":10  
 }  

Click the "Send" button:
If all It is ok, you will receive a Status 200 OK


If you refresh SQL Developer you can find the new row:




7 commenti:

  1. Risposte
    1. IEEE Cloud computing DOamin is a general term for anything that involves delivering hosted services over the Internet. IEEE Projects on Cloud Computing The cloud is a metaphor for a global network of remote servers which operates as a single ecosystem, commonly associated with the Internet. IEEE FInal Year Project Domains Final Year Projects for CSE cloud computing is the delivery of computing services—including servers, storage, databases, networking, software, analytics, and intelligence


      JavaScript Training in Chennai


      JavaScript Training in Chennai

      Elimina
  2. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted "Oracle Training in Bangalore"."Devops Training in Bangalore"

    RispondiElimina
  3. This Blog Provides Very Useful and Important Information. I just Want to share this blog with my friends and family members. United States Medical Licensing Examination

    RispondiElimina