On Tue, 2 Jun 2009 10:35:12 -0300, Karl Brandt <brandk...@gmail.com> wrote:
>2009/6/2 J. King <jk...@jkingweb.ca> >> >> On Tue, 02 Jun 2009 07:40:01 -0400, Karl Brandt <brandk...@gmail.com> >> wrote: >> >> > I'm trying to set the conflict resolution of an entire transaction by >> > using the ON CONFLICT clause without success. >> > >> > [...] >> > >> > Is there a way to set the conflict resolution for an entire transaction? >> >> Such a thing is not possible. You may specify a conflict resolution on a >> given statement (eg. 'INSERT OR ROLLBACK') or on a table (on PRIMARY KEY, >> NOT NULL and UNIQUE constraints), but not on a transaction. > >Thanks for the info. > >Let me explain the complete picture so someone can help me. > >I develop a wrapper around sqlite that tracks the changed records and >than save the changes to the database by building and executing a SQL >query (a transaction). > >Currently it executes the SQL and check the return value. >If the return value is different from SQLITE_OK it executes a >separated ROLLBACK command so another transaction can be started. > >The problem is that after the ROLLBACK command, sqlite3_errmsg will >return "no error", giving the user no clues of what happened. > >I tried INSERT OR ROLLBACK syntax but it will work only for >SQLITE_CONSTRAINT. I would need to handle also SQLITE_ERROR. > >So there's a way to check if a transaction failed (for constraint or >another error) and than rollback without clearing the error message >returned by sqlite3_errmsg? After a ROLLBACK; there is no error (ROLLBACK is succesful), so the error message will be cleared. You can use INSERT .... ON CONFLICT ABORT ... ; Catch the constraint error, fetch the sqlite3_errmsg() and ROLLBACK yourself. http://www.sqlite.org/lang_conflict.html (untested) >Thanks in advance. > >Luiz -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users