?
Solved

How do I prevent a recursive Interbase trigger

Posted on 2010-09-23
2
Medium Priority
?
1,263 Views
Last Modified: 2013-12-09
How do I update multiple rows in a table using a trigger without encounting a recursive trigger scenario? For instance, you change the price for an item in Group 1, the idea would be for the trigger to set the price for every other item in the table in Group 1 to the same price. However, this is an easy scenario to encounter a recursive trigger when running an update statement on the same table. Any ideas on how to accomplish this with a trigger or trigger/procedure?

Example:

Item     Price     Group
Item1   1.00      1
Item2   2.00      2
Item3   1.00      1

Edit price for Item 1 to 3.00 should also change Item3 to 3.00.
0
Comment
Question by:PilotAdmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
NickUpson earned 1500 total points
ID: 33752300
in an after update trigger

if exists (select 1 from mytable where group = new.group and price <> new.price)) then
  update mytable set price = new.price where group = new.group;

this is untested pseudo code, but you should get the idea






0
 

Author Closing Comment

by:PilotAdmin
ID: 33798466
After update suggestion worked.. had to manage it a bit different due to the example I provided being a little oversimplified (we have a lot more going on in the price table that I didn't go into), but it did get me going down the right track. Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we’ll look at how to deploy ProxySQL.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question