Batch Operation
Batch Operation
The batch operation allows you to execute batch INSERTs, UPDATEs, and DELETEs against your data sources using a single request.
Request Format
POST /batch
Request Body
All requests must include a JSON body like the following:
{
"query": "<string>",
"defaultSchema": "<string>",
"parameters": [
{
"@p1": { "dataType": <int>, "value": <any> },
"@p2": { "dataType": <int>, "value": <any> },
...
},
...
]
}
Fields
query | Required | The batch INSERT, UPDATE, or DELETE statement to execute. |
defaultSchema | Optional | If any tables mentioned in query are not prefixed with a schema name, this property must be used to specify a default schema. |
parameters | Optional | A JSON object containing a list of query parameter sets (more info below). All parameter names must begin with @ . |
dataType | Required | The parameter’s data type. |
value | Required | The parameter’s value. |
Note that, unlike the /query operation, this operation’s parameters
property is an array of parameter set objects instead of a single parameter set object. Each parameter set in the array represents the parameters for a single item in the batch, and all parameter sets must contain the exact same set of parameter names.
Response Format
The batch query’s result set is returned in our standard JSON result object.
Example
POST https://cloud.cdata.com/api/batch
Request Body
{
"query": "INSERT INTO Salesforce1.Salesforce.Account (Salesforce1.Salesforce.Account.Name, Salesforce1.Salesforce.Account.BillingCity) VALUES (@p1, @p2)",
"timeout": 60,
"parameters": [
{
"@p1": {"dataType": 5, "value": "New Cars"},
"@p2": {"dataType": 5, "value": "San Francisco"}
},
{
"@p1": {"dataType": 5, "value": "Clean Linens"},
"@p2": {"dataType": 5, "value": "New York"}
},
{
"@p1": {"dataType": 5, "value": "CData Software"},
"@p2": {"dataType": 5, "value": "Chapel Hill"}
}
]
}
Response
{
"results": [
{
"AffectedRows": 1
},
{
"AffectedRows": 1
},
{
"AffectedRows": 1
}
]
}