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

Reply via email to