I have this simple schema:

create table words
(
    _id integer primary key autoincrement,
    wordText text not null unique
);

I have triggers that work, which I got from 
http://www.sqlite.org/cvstrac/wiki?p=ForeignKeyTriggers.

Now I'm trying to modify the update trigger to prevent saving a word 
with the same ID but different text:

create trigger ut_words_cannotChangeWordTextOnUpdate
before update on words
for each row
begin
    select raise(
        rollback,
        'update on table WORDS violates constraint 
ut_words_cannotChangeWordTextOnUpdate')
    where OLD.wordText <> NEW.wordText;
end;

The schema seems to load without a problem, and I'm able to run my 
unit tests up to the point where I save a word with the same ID but 
with the wordText set to the existing word's wordText + "_different" 
(in other words, different text).

I expect a SQLiteConstraintException to be thrown, but no exception is 
thrown. It saves the modified word with the same ID, which it 
shouldn't be doing.

Yes, the trigger is being installed.

Is the trigger written incorrectly, or should I be looking somewhere 
else for the cause? If elsewhere, where? 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to