Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

Note: You are viewing the documentation for an older major version of the AWS CLI (version 1).

AWS CLI version 2, the latest major version of AWS CLI, is now stable and recommended for general use. To view this page for the AWS CLI version 2, click here. For more information see the AWS CLI version 2 installation instructions and migration guide.

[ aws . rds-data ]

batch-execute-statement

Description

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.

Warning

If a call isn't part of a transaction because it doesn't include the transactionID parameter, changes that result from the call are committed automatically.

See also: AWS API Documentation

See 'aws help' for descriptions of global parameters.

Synopsis

  batch-execute-statement
[--database <value>]
[--parameter-sets <value>]
--resource-arn <value>
[--schema <value>]
--secret-arn <value>
--sql <value>
[--transaction-id <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--database (string)

The name of the database.

--parameter-sets (list)

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.

Note

Array parameters are not supported.

JSON Syntax:

[
  [
    {
      "name": "string",
      "typeHint": "DATE"|"DECIMAL"|"TIME"|"TIMESTAMP",
      "value": {
        "arrayValue": {
          "arrayValues": [
            {
              "arrayValues": [
                { ... recursive ... }
                ...
              ],
              "booleanValues": [true|false, ...],
              "doubleValues": [double, ...],
              "longValues": [long, ...],
              "stringValues": ["string", ...]
            }
            ...
          ],
          "booleanValues": [true|false, ...],
          "doubleValues": [double, ...],
          "longValues": [long, ...],
          "stringValues": ["string", ...]
        },
        "blobValue": blob,
        "booleanValue": true|false,
        "doubleValue": double,
        "isNull": true|false,
        "longValue": long,
        "stringValue": "string"
      }
    }
    ...
  ]
  ...
]

--resource-arn (string)

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

--schema (string)

The name of the database schema.

--secret-arn (string)

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

--sql (string)

The SQL statement to run.

--transaction-id (string)

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.

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Examples

To execute a batch SQL statement

The following batch-execute-statement example executes a batch SQL statement over an array of data with a parameter set.

aws rds-data batch-execute-statement \
    --resource-arn "arn:aws:rds:us-west-2:123456789012:cluster:mydbcluster" \
    --database "mydb" \
    --secret-arn "arn:aws:secretsmanager:us-west-2:123456789012:secret:mysecret" \
    --sql "insert into mytable values (:id, :val)" \
    --parameter-sets "[[{\"name\": \"id\", \"value\": {\"longValue\": 1}},{\"name\": \"val\", \"value\": {\"stringValue\": \"ValueOne\"}}],
        [{\"name\": \"id\", \"value\": {\"longValue\": 2}},{\"name\": \"val\", \"value\": {\"stringValue\": \"ValueTwo\"}}],
        [{\"name\": \"id\", \"value\": {\"longValue\": 3}},{\"name\": \"val\", \"value\": {\"stringValue\": \"ValueThree\"}}]]"

This command produces no output.

For more information, see Using the Data API for Aurora Serverless in the Amazon RDS User Guide.

Output

updateResults -> (list)

The execution results of each batch entry.

(structure)

The response elements represent the results of an update.

generatedFields -> (list)

Values for fields generated during the request.

(structure)

Contains a value.

arrayValue -> (structure)

An array of values.

arrayValues -> (list)

An array of arrays.

(structure)

Contains an array.

arrayValues -> (list)

An array of arrays.

( ... recursive ... )

booleanValues -> (list)

An array of Boolean values.

(boolean)

doubleValues -> (list)

An array of integers.

(double)

longValues -> (list)

An array of floating point numbers.

(long)

stringValues -> (list)

An array of strings.

(string)

booleanValues -> (list)

An array of Boolean values.

(boolean)

doubleValues -> (list)

An array of integers.

(double)

longValues -> (list)

An array of floating point numbers.

(long)

stringValues -> (list)

An array of strings.

(string)

blobValue -> (blob)

A value of BLOB data type.

booleanValue -> (boolean)

A value of Boolean data type.

doubleValue -> (double)

A value of double data type.

isNull -> (boolean)

A NULL value.

longValue -> (long)

A value of long data type.

stringValue -> (string)

A value of string data type.