on ‎2019 Jun 27 4:07 PM
Hi Experts,
I am developing an Node.js service to expose data from HANA in an MTA application in XSA. I have written Multiple inserts in an app.post to insert records in more than one table . I want the database to rollback the inserts if any of the insert fails.
Could you please suggest solutions to achieve the rollback functionality. I am using async and await in app.post() to execute the insert queries.
Below is the code snippets.
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
By default the autoCommit option is set, so each inserts commits if no error occurred. One option to reach what you wanna have is to disable the auto commit using function setAutoCommit(false) on the db connection. Then do your inserts. In case of an error execute function rollback() on the db connection. In case of no error function success(). Afterwards (in both bases) enable the autoCommit option again.
If wanna do in general the commit/rollback handling by yourself you can set the autoCommit option to false when the db connection is created.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.