executeStatement method

Future<ExecuteStatementResponse> executeStatement({
  1. required String resourceArn,
  2. required String secretArn,
  3. required String sql,
  4. bool? continueAfterTimeout,
  5. String? database,
  6. RecordsFormatType? formatRecordsAs,
  7. bool? includeResultMetadata,
  8. List<SqlParameter>? parameters,
  9. ResultSetOptions? resultSetOptions,
  10. String? schema,
  11. String? transactionId,
})

Runs a SQL statement against a database.

If the binary response data from the database is more than 1 MB, 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. May throw UnsupportedResultException.

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.

Alternatively, disable shell history expansion by running set +H before you execute the command.

Parameter sql : The SQL statement to run.

Parameter continueAfterTimeout : A value that indicates whether to continue running the statement after the call times out. By default, the statement stops running when the call times out.

Parameter database : The name of the database.

Parameter formatRecordsAs : A value that indicates whether to format the result set as a single JSON string. This parameter only applies to SELECT statements and is ignored for other types of statements. Allowed values are NONE and JSON. The default value is NONE. The result is returned in the formattedRecords field.

For usage information about the JSON format for result sets, see Using the Data API in the Amazon Aurora User Guide.

Parameter includeResultMetadata : A value that indicates whether to include metadata in the results.

Parameter parameters : The parameters for the SQL statement.

Parameter resultSetOptions : Options that control how the result set is returned.

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<ExecuteStatementResponse> executeStatement({
  required String resourceArn,
  required String secretArn,
  required String sql,
  bool? continueAfterTimeout,
  String? database,
  RecordsFormatType? formatRecordsAs,
  bool? includeResultMetadata,
  List<SqlParameter>? parameters,
  ResultSetOptions? resultSetOptions,
  String? schema,
  String? transactionId,
}) async {
  final $payload = <String, dynamic>{
    'resourceArn': resourceArn,
    'secretArn': secretArn,
    'sql': sql,
    if (continueAfterTimeout != null)
      'continueAfterTimeout': continueAfterTimeout,
    if (database != null) 'database': database,
    if (formatRecordsAs != null) 'formatRecordsAs': formatRecordsAs.value,
    if (includeResultMetadata != null)
      'includeResultMetadata': includeResultMetadata,
    if (parameters != null) 'parameters': parameters,
    if (resultSetOptions != null) 'resultSetOptions': resultSetOptions,
    if (schema != null) 'schema': schema,
    if (transactionId != null) 'transactionId': transactionId,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/Execute',
    exceptionFnMap: _exceptionFns,
  );
  return ExecuteStatementResponse.fromJson(response);
}