2

I have a simple problem with sql transactions. I connect to my database in method A and start a sql transaction. At the end of the method I close the connection, because the calculation (external method) takes a long time.
After finishing the calculation I want to commit or rollback the transaction, but I need the same connection.

Is there any other possibility to get it running?

CSchulz
  • 10,882
  • 11
  • 60
  • 114

2 Answers2

1

The only thing I can think of is to not do any writing in the half, then you won't have to do anything if you decide to rollback later on.

Andy
  • 1,452
  • 1
  • 13
  • 18
0

I would use the SQL transaction model for an operation that needs to remain open for a long period of time. Depending on what you're actually doing, there's probably a superior solution. It might involve a "calculation in progress" SQL table, it might not.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278