cancel
Showing results for 
Search instead for 
Did you mean: 

Create Multiple records at a time

former_member194533
Participant
0 Kudos

Hi Experts ,

I am using the below OData service :

http://services.odata.org/V2/(S(u0fm33whthkboho0u01zhgyh))/OData/OData.svc

Using this Odata service I am able to Perform CREATE , READ , UPDATE , DELETE but only one record at a time .

eg: for creating a new record I am using the below code :

var oModel = new sap.ui.model.odata.ODataModel("proxy/http/services.odata.org/V2/(S(u0fm33whthkboho0u01zhgyh))/OData/OData.svc", true);

  oModel.create("/Products",{

  ID: "11",

  Name: "Honey",

  Description: "Healthy"

  },{

  success: function()

  {

alert("success");

  },

  error: function(){

  alert("failure");

  }

  });

Now My requirement is to create multiple records , update multiple records , Delete multiple records at a time . Can anybody help with code for this same example .

Thanks

Rizwan

Accepted Solutions (1)

Accepted Solutions (1)

daniel_ruiz2
Active Contributor
0 Kudos

Hi,

OData does not have such concept - the best you can do is to use $batch which is terribly slow (not just slow but rather shocking slow) to submit multiple "requests" at once in a multipart/boundary type of form. One can create a batch for different operations.

Alternatively, the OData v2 supports a "create deep" which means you can create inner entities on the same request.. this way you could create a "new" entity say "ProductBatch" which is a collection of Products and nothing else and use such in a create deep operation sending a lot of products at once. While this approach is "not correct" - it's the only viable option as far I'm aware if you're not happy with general performance of the Gateway System, most of all dealing with $batch requests.

Hope it helps,

Dan.

former_member194533
Participant
0 Kudos

Hi Deniel ,

      Its not about this products odata service . In general take any odata service , I want to know how can we create multiple records , update multiple records and delete multiple records at a time .

If possible help me with code .

Thanks

Rizwan

Qualiture
Active Contributor
0 Kudos

As Daniel said, you should use batch requests. See this excellent blog

former_member194533
Participant
0 Kudos

Hi Robin ,

     I tried with your link . Its working perfectly  . Thank you sooooooooooooooo Much for your help .

Thanks

Rizwan

Answers (1)

Answers (1)

venkatachala_ck
Active Participant
0 Kudos

Hi Rizwan Pasha,

check out this link i think you  will get some idea

Regards

Venkat