On 2 Oct 2010, at 12:04am, Jim Mellander wrote:

> I tried your trigger:
> 
> CREATE TRIGGER auto_delete_summary AFTER DELETE ON detail
> FOR EACH ROW WHEN NOT EXISTS (SELECT * FROM detail WHERE key = OLD.key)
> BEGIN
>  DELETE FROM summary WHERE key = OLD.key;
> END;
> 
> and it works as advertised, but I would like to understand why.  I'm a
> bit hazy on why the FOR EACH ROW statement works.  Does FOR EACH ROW
> refer to each row that is being removed from 'detail'?

'FOR EACH ROW' reflects other possibilities defined in SQL which SQLite doesn't 
support right now.  This page

http://www.sqlite.org/lang_createtrigger.html

describes what it means.  The alternative would be 'FOR EACH STATEMENT' and the 
two would be different if one UPDATE command would make a change in more than 
one row in the database.

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

Reply via email to