As a newbie just learning SQL, this looks like a foreign key situation
- unfortunately I'm using the standard snowleopard sqlite which is
3.6.12, which appears to not support foreign key constraints.

Assuming I upgrade, I presume I can add the summary record with a
BEFORE trigger if it isn't there, and attempt delete of the summary
record with an AFTER trigger, which will not occur if the foreign key
constraint is set correctly.  Would this be an accurate understanding?


On Fri, Oct 1, 2010 at 2:38 PM, Jim Mellander <jmellan...@lbl.gov> wrote:
> Hi:
>
> I want to use to trigger on deletion of a detail record to
> automatically delete a summary record, if not more detail records
> exist, something like:
>
> CREATE TRIGGER detail_delete AFTER DELETE ON detail
>    BEGIN
>        -- here I don't know syntax
>       IF COUNT(detail records with key) = 0 DELETE summary WHERE key=old.key;
>    END;
>
>
> Is something like this possible to do?  Any suggestions.
>
> Thanks in advance
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to