Updating a foreign key  Insert trigger example using multiple rows

Chapter 19: Triggers: Enforcing Referential Integrity

Multirow considerations

Multirow considerations are particularly important when the function of a trigger is to recalculate summary values, or provide ongoing tallies.

Triggers used to maintain summary values should contain group by clauses or subqueries that perform implicit grouping. This creates summary values when more than one row is being inserted, updated, or deleted. Since a group by clause imposes extra overhead, the following examples are written to test whether @@rowcount = 1, meaning that only one row in the trigger table was affected. If @@rowcount = 1, the trigger actions take effect without a group by clause.





Copyright © 2005. Sybase Inc. All rights reserved. Insert trigger example using multiple rows

View this book as PDF