DVA-C02 · Question #773
DVA-C02 Question #773: Real Exam Question with Answer & Explanation
The correct answer is D: Implement try-catch statements. Run the SQL queries within a transaction. Use Begin. To guarantee automatic rollback when any query in a batch fails, the queries must be executed within an explicit database transaction. Using the RDS Data API transaction lifecycle APIs ensures atomicity: BeginTransaction starts the transaction, CommitTransaction persists all chan
Question
An application uses the Amazon RDS Data API to write data to a PostgreSQL database that is hosted in an Amazon Aurora DB cluster. The application receives predefined SQL queries in batches. Each batch consists of a maximum of 10 queries. The application runs the SQL queries in a loop by using the ExecuteStatement API call. A developer observes that some queries fail. The developer must ensure that an automatic rollback happens whenever a query fails. Which solution will meet these requirements?
Options
- AImplement try-catch statements for the ExecuteStatement API call. Use Rollback Transaction API
- BImplement try-catch statements. Replace the ExecuteStatement API call with an ExecuteSql API
- CImplement try-catch statements. Replace the ExecuteStatement API call with a
- DImplement try-catch statements. Run the SQL queries within a transaction. Use Begin
Explanation
To guarantee automatic rollback when any query in a batch fails, the queries must be executed within an explicit database transaction. Using the RDS Data API transaction lifecycle APIs ensures atomicity: BeginTransaction starts the transaction, CommitTransaction persists all changes only if every query succeeds, and RollbackTransaction reverts all changes if an error occurs. This approach reliably enforces rollback behavior across multiple SQL statements.
Community Discussion
No community discussion yet for this question.