Solved

How do I prevent a recursive Interbase trigger

Posted on 2010-09-23
2
1,260 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 500 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

696 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