Transaction For Prepared Statements Using Node Mssql
I want to create an Express REST API and will use MSSQL for the database part. I use the mssql module and use the PreparedStatement class. Sometimes my queries have to be transact
Solution 1:
I believe the error you're hitting happens because you didn't call unprepare
as suggested in the docs:
keep in mind you can't execute other requests in the transaction until you call unprepare
Calling unprepare
on the statement before rolling back the transaction works for me:
try {
// ...
await invalidStatement.prepare('INSERT INTO integer (value) VALUES (@number)');
try {
await invalidStatement.execute({ number: false });
} finally {
await invalidStatement.unprepare();
}
} catch (error) {
// rollback here...
}
Post a Comment for "Transaction For Prepared Statements Using Node Mssql"