Narutokk
Narutokk

Reputation: 1034

Can i keep a transaction alive while killing corrensponding connection?

in sql server, if i begin a transaction, and close that application, the transaction will be roll back automatically.

i wonder if there 's any way to keep alive the transaction when the app is down.

Upvotes: 1

Views: 107

Answers (2)

alekseyk
alekseyk

Reputation: 143

When you're committing to the DB you're basically saying that the data to be written is correct and processed by the application. Data will be written only if transaction is closed, and this contract means, that the DB won't contain invalid/corrupted information. So, no. You cannot keep-alive transactions after you close the connection.

Upvotes: 0

Preet Sangha
Preet Sangha

Reputation: 65496

No I don't think so. I think this design is wrong. You should be using a Compensation approach, not a Transaction approach.

A transaction can lock resources (depending on the isolation strategy). You probably don't want this.

Have a read of this IBM article.

Upvotes: 2

Related Questions