Subject | Re: [firebird-support] Maintaining count with trigger, prevent updating on cascades |
---|---|
Author | Ann W. Harrison |
Post date | 2010-07-15T14:56:32Z |
sqlsvr wrote:
the blog has been deleted, so the trigger will fire, find no
matching record, and stop.
Best regards,
Ann
> I have two tables: blogs and blog posts. Blogs keep a count of blog posts and blog posts has a foreign key (cascade) to blogs. There is a trigger on blog posts that updates the count in blogs table.The cascading delete of the blog posts records happens after
>
> Now, if a blog post is inserted/deleted, I want to update the blogs count. However, if a blog is deleted....it will cascade the delete on the blog posts table.
>
> I'm assuming that this will cause the trigger to execute and update the blogs table unnecessarily? If so, is there anyway to stop it?
the blog has been deleted, so the trigger will fire, find no
matching record, and stop.
Best regards,
Ann