Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with triggers

Status
Not open for further replies.

wekoweko

Programmer
Feb 1, 2004
18
0
0
PH
CREATE OR REPLACE TRIGGER trigger_name
AFTER UPDATE OF column ON table1
FOR EACH ROW
WHEN (NEW.column=some_value)
BEGIN
UPDATE table2 statement1 WHERE condition;
UPDATE table2 statement2 WHERE condition;
END trigger_name;

hey guys need some help on this one, need a trigger to update a row on table2 whenever a column in a row in table1 gets updated, my problem is the trigger updates all the rows in table2 for statement1 and then updates the valid row(WHEN (NEW.column=some_value)) for statement1 and statement2 , could you guys check out my case, condition used for both UPDATE statements are the same, thanks a lot guys
 
Hi there ,

I am confused with what you are saying. Basically cannot understand what is exactly happening ?

Check if there is any other trigger on TABLE1 which is doing the changes ( which you are not expecting ) ?

If its not the case, please explain in more detail about your problem.

Cheers
 
Weko,

If "the trigger updates all the rows in table2", then your WHERE statement is not exclusive enough. If we promise not to tell, could you please post your actual trigger code, then we could probably be more specific in our answers.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 16:56 (19Apr04) UTC (aka "GMT" and "Zulu"), 09:56 (19Apr04) Mountain Time)
 
hey there parbhani and santamufasa, thanks for the replies, yes you guys are right, i checked through toad and true enough there were 2 triggers acting on table1, one owned by sys and one owned by the schema i created, the other trigger had no where clause and so updated all rows of the table and the onther one that had the where clause updated only the valid record, dropped the other trigger and everything is fine now, hehehe my mistake, thanks a lot guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top