batchExecuteStatement method
Runs a batch SQL statement over an array of data.
You can run bulk update and insert operations for multiple records using a DML statement with different parameter sets. Bulk operations can provide a significant performance improvement over individual insert and update operations.
There isn't a fixed upper limit on the number of parameter sets. However, the maximum size of the HTTP request submitted through the Data API is 4 MiB. If the request exceeds this limit, the Data API returns an error and doesn't process the request. This 4-MiB limit includes the size of the HTTP headers and the JSON notation in the request. Thus, the number of parameter sets that you can include depends on a combination of factors, such as the size of the SQL statement and the size of each parameter set.
The response size limit is 1 MiB. If the call returns more than 1 MiB of response data, the call is terminated.
May throw AccessDeniedException.
May throw BadRequestException.
May throw DatabaseErrorException.
May throw DatabaseNotFoundException.
May throw DatabaseResumingException.
May throw DatabaseUnavailableException.
May throw ForbiddenException.
May throw HttpEndpointNotEnabledException.
May throw InternalServerErrorException.
May throw InvalidResourceStateException.
May throw InvalidSecretException.
May throw SecretsErrorException.
May throw ServiceUnavailableError.
May throw StatementTimeoutException.
May throw TransactionNotFoundException.
Parameter resourceArn :
The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.
Parameter secretArn :
The ARN of the secret that enables access to the DB cluster. Enter the
database user name and password for the credentials in the secret.
For information about creating the secret, see Create a database secret.
Parameter sql :
The SQL statement to run. Don't include a semicolon (;) at the end of the
SQL statement.
Parameter database :
The name of the database.
Parameter parameterSets :
The parameter set for the batch operation.
The SQL statement is executed as many times as the number of parameter sets provided. To execute a SQL statement with no parameters, use one of the following options:
- Specify one or more empty parameter sets.
-
Use the
ExecuteStatementoperation instead of theBatchExecuteStatementoperation.
Parameter schema :
The name of the database schema.
Parameter transactionId :
The identifier of a transaction that was started by using the
BeginTransaction operation. Specify the transaction ID of the
transaction that you want to include the SQL statement in.
If the SQL statement is not part of a transaction, don't set this parameter.
Implementation
Future<BatchExecuteStatementResponse> batchExecuteStatement({
required String resourceArn,
required String secretArn,
required String sql,
String? database,
List<List<SqlParameter>>? parameterSets,
String? schema,
String? transactionId,
}) async {
final $payload = <String, dynamic>{
'resourceArn': resourceArn,
'secretArn': secretArn,
'sql': sql,
if (database != null) 'database': database,
if (parameterSets != null) 'parameterSets': parameterSets,
if (schema != null) 'schema': schema,
if (transactionId != null) 'transactionId': transactionId,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/BatchExecute',
exceptionFnMap: _exceptionFns,
);
return BatchExecuteStatementResponse.fromJson(response);
}