batchExecuteStatement method

Future<BatchExecuteStatementResponse> batchExecuteStatement({
  1. required String resourceArn,
  2. required String secretArn,
  3. required String sql,
  4. String? database,
  5. List<List<SqlParameter>>? parameterSets,
  6. String? schema,
  7. String? transactionId,
})

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.

May throw BadRequestException. May throw StatementTimeoutException. May throw InternalServerErrorException. May throw ForbiddenException. May throw ServiceUnavailableError.

Parameter resourceArn : The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster.

Parameter secretArn : The name or ARN of the secret that enables access to the DB cluster.

Parameter sql : The SQL statement to run.

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 ExecuteStatement operation instead of the BatchExecuteStatement operation.

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 {
  ArgumentError.checkNotNull(resourceArn, 'resourceArn');
  _s.validateStringLength(
    'resourceArn',
    resourceArn,
    11,
    100,
    isRequired: true,
  );
  ArgumentError.checkNotNull(secretArn, 'secretArn');
  _s.validateStringLength(
    'secretArn',
    secretArn,
    11,
    100,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sql, 'sql');
  _s.validateStringLength(
    'sql',
    sql,
    0,
    65536,
    isRequired: true,
  );
  _s.validateStringLength(
    'database',
    database,
    0,
    64,
  );
  _s.validateStringLength(
    'schema',
    schema,
    0,
    64,
  );
  _s.validateStringLength(
    'transactionId',
    transactionId,
    0,
    192,
  );
  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);
}