Batch Operation
Version 22.0.8486
Version 22.0.8486
Batch Operation
The batch operation allows users to execute batch INSERT, UPDATE, and delete queries using a single request.
Request Format
POST /rest.rsc/batch
Request Body
All requests must include a JSON body like the following:
{
"query": "<string>",
"defaultSchema": "<string>",
"timeout": <int>,
"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. |
timeout | Required | The command timeout of the SQL query in seconds. Default is 60. |
parameters | Required | A JSON array that contains one or more JSON objects, each of which contains a set of query parameters (more info below). All parameter names must begin with @ . |
dataType | Required | The parameter’s data type. Default is 5. |
value | Required | The parameter’s value. |
Note: The 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 the standard JSON result object.
Example
POST https://myconnectserver/rest.rsc/batch
Request Body
{
"query": "INSERT INTO Salesforce1.Account (Salesforce1.Account.Name, Salesforce1.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
Result sets are returned in JSON format, with an application/json content type header value. The response returns the number of affected items.
{
"results": [
{
"AffectedRows": 1
},
{
"AffectedRows": 1
},
{
"AffectedRows": 1
}
]
}