Using MultiWrite API to insert data

You can add more than a row of data in a single database operation using MultiWrite API.

You can perform a sequence of PutRequest operations associated with a table that share the same shard key portion of their primary keys as a single atomic write operation using the WriteMultipleRequest class. You can also simultaneously add data to a parent and child table using the WriteMultipleRequest class. This is an efficient way to atomically modify multiple related rows. If the operation is successful, the WriteMultipleResult.getSuccess() method returns true.

See Oracle NoSQL Java SDK API Reference for more details on the various classes and methods.

Download the full code MultiWrite.java from the examples here.
private static void writeMul(NoSQLHandle handle,String parent_tblname, 
String parent_data, String child_tblname, String child_data){
      WriteMultipleRequest umRequest = new WriteMultipleRequest();
      PutRequest putRequest =
         new PutRequest().setValueFromJson(parent_data,null).setTableName(parent_tblname);
      umRequest.add(putRequest, false);
      putRequest =
         new PutRequest().setValueFromJson(child_data,null).setTableName(child_tblname);
      umRequest.add(putRequest, false);
      WriteMultipleResult umResult = handle.writeMultiple(umRequest);
}

You can perform a sequence of PutRequest operations associated with a table that share the same shard key portion of their primary keys as a single atomic write operation using the borneo.WriteMultipleRequest class. You can also simultaneously add data to a parent and child table using the borneo.WriteMultipleRequest class. This is an efficient way to atomically modify multiple related rows.

See Oracle NoSQL Python SDK API Reference for more details on the various classes and methods.

Download the full code MultiWrite.py from the examples here.
def mul_write(handle,parent_tblname,parent_data,
child_tblname, child_data):
    request = PutRequest()
    request.set_value_from_json(parent_data)
    request.set_table_name('ticket')
    wm_req.add(request, True)
    request1 = PutRequest()
    request1.set_table_name(child_tblname)
    request1.set_value_from_json(child_data)
    wm_req.add(request1, True)
    result = handle.write_multiple(wm_req)

You can perform a sequence of PutRequest operations associated with a table that share the same shard key portion of their primary keys as a single atomic write operation using the WriteMultipleRequest class. You can also simultaneously add data to a parent and child table using the WriteMultipleRequest class. This is an efficient way to atomically modify multiple related rows.

See Oracle NoSQL Go SDK API Reference for more details on the various classes and methods.

Download the full code MultiWrite.go from the examples here.
//multiple write from the table
func mul_write(client *nosqldb.Client, err error, parenttbl_name string,
parent_data string, childtbl_name string, child_data string)(){
   value, err := types.NewMapValueFromJSON(parent_data)
	putReq := &nosqldb.PutRequest{
      TableName: parenttbl_name,
      Value:     value,
   }
	wmReq := &nosqldb.WriteMultipleRequest{
		TableName: "",
		Timeout:   10 * time.Second,
	}
   wmReq.AddPutRequest(putReq, true)

	value1, err := types.NewMapValueFromJSON(child_data)
	putReq1 := &nosqldb.PutRequest{
      TableName: childtbl_name,
      Value:     value1,
   }
   wmReq.AddPutRequest(putReq1, true)
	wmRes, err := client.WriteMultiple(wmReq)
	if err != nil {
		fmt.Printf("WriteMultiple() failed: %v\n", err)
		return
	}
	if wmRes.IsSuccess() {
		fmt.Printf("WriteMultiple() succeeded\n")
	} else {
		fmt.Printf("WriteMultiple() failed\n")
	}
}

You can perform a sequence of put operations associated with a table that share the same shard key portion of their primary keys as a single atomic write operation using the writeMany method. You can also simultaneously add data to a parent and child table using the writeMany method. This is an efficient way to atomically modify multiple related rows.

For method details, see NoSQLClient class.

JavaScript: Download the full code MultiWrite.js from the examples here.
const ops = [
               {
                  tableName: 'ticket',
                  put: {
                     "ticketNo": "1762344493810",
                     "confNo" : "LE6J4Z"
                  },
                  abortOnFail: true
               },
               {
                  tableName: 'ticket.bagInfo',
                  put: {
                     "ticketNo":"1762344493810",
                     "id":"79039899165297",
                     "tagNum":"17657806255240",
                     "routing":"MIA/LAX/MEL",
                     "lastActionCode":"OFFLOAD",
                     "lastActionDesc":"OFFLOAD",
                     "lastSeenStation":"MEL",
                     "lastSeenTimeGmt":"2019-02-01T16:13:00Z",
                     "bagArrivalDate":"2019-02-01T16:13:00Z"
                   },
                  abortOnFail: true
               }
            ];

const res = await handle.writeMany(ops, null);
TypeScript: Download the full code MultiWrite.ts from the examples here.
const ops = [
               {
                  tableName: 'ticket',
                  put: {
                     "ticketNo": "1762344493810",
                     "confNo" : "LE6J4Z"
                  },
                  abortOnFail: true
               },
               {
                  tableName: 'ticket.bagInfo',
                  put: {
                     "ticketNo":"1762344493810",
                     "id":"79039899165297",
                     "tagNum":"17657806255240",
                     "routing":"MIA/LAX/MEL",
                     "lastActionCode":"OFFLOAD",
                     "lastActionDesc":"OFFLOAD",
                     "lastSeenStation":"MEL",
                     "lastSeenTimeGmt":"2019-02-01T16:13:00Z",
                     "bagArrivalDate":"2019-02-01T16:13:00Z"
                   },
                  abortOnFail: true
               }
            ];

const res = await handle.writeMany(ops, null);

You can perform a sequence of put operations associated with a table that share the same shard key portion of their primary keys as a single atomic write operation using the PutManyAsync method. You can also simultaneously add data to a parent and child table using the PutManyAsync method. This is an efficient way to atomically modify multiple related rows.

See Oracle NoSQL Dotnet SDK API Reference for more details of all classes and methods.

Download the full code MultiWrite.cs from the examples here.
private static async Task mul_write(NoSQLClient client,string parentbl_name,
string data1, string childtbl_name, string data2){
    var result = await client.WriteManyAsync(
        new WriteOperationCollection()
          .AddPut(parentbl_name, FieldValue.FromJsonString(data1).AsMapValue)
          .AddPut(childtbl_name, FieldValue.FromJsonString(data2).AsMapValue)
         );
    }