Should have included the code that calls: long id = mDatabase.insert(tableName, null, contentValues);
if (id == -1) { throw new AppException(message, ErrorCodes.INSERT_FAILED); } The AppException is thrown. But when insert returns -1, that just means there was an error. Where is the specific error code? Is Android swallowing raised exceptions and turning them all into just -1? ----- Original Message ----- From: "Jim Showalter" <j...@jimandlisa.com> To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org> Sent: Sunday, July 12, 2009 6:03 PM Subject: [sqlite] Raise is not working > Schema: > > create table words (_id integer primary key autoincrement, wordtext > text not null unique); > > create table definitions (_id integer primary key autoincrement, > owningWordId integer not null unique, deftext text not null); > > create trigger fki_definitions_words_id before insert on definitions > for each row > begin > select raise (rollback, 'insert on table definitions violates > foreign-key constraint fki_definitions_words_id') > where (select _id from words where _id = NEW.owningWordId ) is > null; > > end; > > Call db.insert, passing it a definition that has the owningWordId > set > to -1, and the insert returns a -1 instead of throwing. > > Because it doesn't throw, I don't have the error message "insert on > table definitions violates foreign-key constraint > fki_definitions_words_id" to work from. Information is simply lost. > > Why isn't it raising an exception? > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users