- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
BeginTransactionCommand
Starts a SQL transaction.
A transaction can run for a maximum of 24 hours. A transaction is terminated and rolled back automatically after 24 hours.
A transaction times out if no calls use its transaction ID in three minutes. If a transaction times out before it's committed, it's rolled back automatically.
For Aurora MySQL, DDL statements inside a transaction cause an implicit commit. We recommend that you run each MySQL DDL statement in a separate ExecuteStatement
call with continueAfterTimeout
enabled.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { RDSDataClient, BeginTransactionCommand } from "@aws-sdk/client-rds-data"; // ES Modules import
// const { RDSDataClient, BeginTransactionCommand } = require("@aws-sdk/client-rds-data"); // CommonJS import
const client = new RDSDataClient(config);
const input = { // BeginTransactionRequest
resourceArn: "STRING_VALUE", // required
secretArn: "STRING_VALUE", // required
database: "STRING_VALUE",
schema: "STRING_VALUE",
};
const command = new BeginTransactionCommand(input);
const response = await client.send(command);
// { // BeginTransactionResponse
// transactionId: "STRING_VALUE",
// };
BeginTransactionCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
resourceArn Required | string | undefined | The Amazon Resource Name (ARN) of the Aurora Serverless DB cluster. |
secretArn Required | string | undefined | The name or ARN of the secret that enables access to the DB cluster. |
database | string | undefined | The name of the database. |
schema | string | undefined | The name of the database schema. |
BeginTransactionCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
transactionId | string | undefined | The transaction ID of the transaction started by the call. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | You don't have sufficient access to perform this action. |
BadRequestException | client | There is an error in the call or in a SQL statement. (This error only appears in calls from Aurora Serverless v1 databases.) |
DatabaseErrorException | client | There was an error in processing the SQL statement. |
DatabaseNotFoundException | client | The DB cluster doesn't have a DB instance. |
DatabaseResumingException | client | A request was cancelled because the Aurora Serverless v2 DB instance was paused. The Data API request automatically resumes the DB instance. Wait a few seconds and try again. |
DatabaseUnavailableException | server | The writer instance in the DB cluster isn't available. |
ForbiddenException | client | There are insufficient privileges to make the call. |
HttpEndpointNotEnabledException | client | The HTTP endpoint for using RDS Data API isn't enabled for the DB cluster. |
InternalServerErrorException | server | An internal error occurred. |
InvalidResourceStateException | client | The resource is in an invalid state. |
InvalidSecretException | client | The Secrets Manager secret used with the request isn't valid. |
SecretsErrorException | client | There was a problem with the Secrets Manager secret used with the request, caused by one of the following conditions:
|
ServiceUnavailableError | server | The service specified by the |
StatementTimeoutException | client | The execution of the SQL statement timed out. |
TransactionNotFoundException | client | The transaction ID wasn't found. |
RDSDataServiceException | Base exception class for all service exceptions from RDSData service. |