How Important are Transactions for SQL?

lip

Active Member
Licensed User
Longtime User
My App uses quite a lot of SQL. There is a background service listening for Bluetooth messages which responds by inserting SQL records based on the messages received.

The app occasionally stops for no obvious reason but I have not managed to trap this in Debug mode yet. It is typically after it has been running for half an hour or so.

I use SQL.ExecNonQuery(...) etc but I am not using Transactions. Could it be that the Service is trying to run more than one SQL command at the same time and if so will putting them all into Transactions solve the problem?

Thanks for any advice...
 

lip

Active Member
Licensed User
Longtime User
Sticky Service

If you are running that on a service, then perhaps the OS is killing your app.

Read about Service or Sticky Service

Thanks for this. Reading the links on Sticky Services It seems that the Service will only be killed if the Main activity has been closed? Is this the case or could the Service just stop, even though it is active itself and the main Activity is still alive and on the screen?
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
As Erel has stated to me: "The writing operations should be about 100 times faster". Yes, this is true - if not faster...

I use them EVERYTIME I have more than 1 record to insert or update.
No penalty for using them all the time, if unsure how many records may be affected by an update - for example.
 
Upvote 0

lip

Active Member
Licensed User
Longtime User
SQL Speed


I am generally only inserting one record at a time so speed is not an issue. Meanwhile a Service module might insert up to a maximum of 10 records at a time. My concern is whether I could be trying to insert a record from the Main activity at the same moment that the background Service decides to add 10 records. Would this cause an error? If so would using Transactions help? I could add Transactions throughout the project but it will take me a few hours and if its not necessary then it will just add confusion to the code.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…