Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use savepoints in SQLite3 in Objective-C
    primarykey
    data
    text
    <p>I'm working on an iOS app that has a rather large sqlite database that gets at least once a day and I'd like to use savepoints to restore it if something happens while the transactions are running.</p> <p>The statements I've been running are the following:</p> <pre><code>const char *sqlSetSavePoint = @"savepoint updateSavepoint"; const char *sqlRollback = @"Rollback transaction to savepoint updateSavepoint"; </code></pre> <p>I have obviously omitted a lot of code that actually runs these statements, but since I'm running the same method for other statements and they work fine I have confidence that the problem isn't there. I'm setting the savepoint before running my insert transactions (inserting up to 200 thousand lines) and then if something throws an exception or an error I try to do a rollback.</p> <p>My questions is; are these rollback statements correct (and I'm just doing something wrong) or is there some other way of using savepoints in sqlite3 in iOS?</p> <p>EDIT: Just for clarification, I'm trying to set a savepoint before then running a number of transactions and if any of them, or a data fetch from the server, fail I want to do a total rollback to the savepoint. It is simply like this:</p> <pre><code>"savepoint updateSavepoint" -&gt;FetchDatafromServer() -&gt; "Begin exclusive transaction" //sqlite3_bind functions -&gt; "Commit transaction" -&gt;FetchDatafromServer() -&gt; "Begin exclusive transaction" //sqlite3_bind functions -&gt; "Commit transaction" -&gt;FetchDatafromServer() -&gt; "Begin exclusive transaction" //sqlite3_bind functions -&gt; "Commit transaction" -&gt;FetchDatafromServer() -&gt; "Begin exclusive transaction" !!Failure!! "Rollback transaction to savepoint updateSavepoint" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload