[ 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 | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--cli-auto-prompt <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.

(list)

(structure)

A parameter used in a SQL statement.

name -> (string)

The name of the parameter.

typeHint -> (string)

A hint that specifies the correct object type for data type mapping.

Values:

  • DECIMAL - The corresponding String parameter value is sent as an object of DECIMAL type to the database.

  • TIMESTAMP - The corresponding String parameter value is sent as an object of TIMESTAMP type to the database. The accepted format is YYYY-MM-DD HH:MM:SS[.FFF] .

  • TIME - The corresponding String parameter value is sent as an object of TIME type to the database. The accepted format is HH:MM:SS[.FFF] .

  • DATE - The corresponding String parameter value is sent as an object of DATE type to the database. The accepted format is YYYY-MM-DD .

value -> (structure)

The value of the parameter.

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.

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 | --cli-input-yaml (string) Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, those 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. This may not be specified along with --cli-input-yaml.

--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. Similarly, if provided yaml-input it will print a sample input YAML that can be used with --cli-input-yaml. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

--cli-auto-prompt (boolean) Automatically prompt for CLI input parameters.

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.