Hello Tobi,

See http://www.sqlite.org/lang_conflict.html, near the bottom:

"When this conflict resolution strategy deletes rows in order to satisfy 
a constraint, it does not invoke delete triggers on those rows. This 
behavior might change in a future release."

I would be interested if an UPDATE - Trigger is invoked instead. Perhaps 
you could try it?

Martin

schachtobi wrote:
> Hello,
>
> i have a question. In my application I issue an insert or replace
> operation. It seems that the delete trigger is not executed here. Is
> there a special replace trigger?
>
> Thanks for your help.
>
> regards,
> Tobias
>
> Here my Session:
> sqlite> select * from ch;
> 1|100_4664.JPG|103|94|98|64
> 2|100_4665.JPG|94|87|88|64
> sqlite> select chId from blobdata;
> 1
> 2
> sqlite> insert or replace into ch(fname) values ('100_4664.JPG');
> sqlite> select chId from blobdata;
> 1
> 2
>
>
> My scheme is:
>
> table|ch|ch|2|CREATE TABLE ch(id INTEGER PRIMARY KEY, fname TEXT
> UNIQUE,       red INTEGER, green INTEGER, blue INTEGER, dsize INTEGER)
>
> index|sqlite_autoindex_ch_1|ch|3|
>
> table|blobdata|blobdata|4|CREATE TABLE blobdata(id INTEGER PRIMARY
> KEY,          data BLOB, chId INTEGER)
>
> trigger|fkd|ch|0|CREATE TRIGGER fkd
>       BEFORE DELETE ON ch
>       FOR EACH ROW BEGIN
>               DELETE from blobdata WHERE chId = OLD.id;
>       END
>
> trigger|fki|blobdata|0|CREATE TRIGGER fki
>       BEFORE INSERT ON blobdata
>       FOR EACH ROW BEGIN
>               SELECT RAISE(ROLLBACK, 'insert invalid')
>                       WHERE (SELECT id FROM ch WHERE id = NEW.chId)
>                       IS NULL;
>       END
>
> index|chIdIdx|blobdata|5|CREATE UNIQUE INDEX chIdIdx ON blobdata(chId)
>
>
>       
> _______________________________________________
> 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

Reply via email to