heu,trigger question [message #1716] |
Thu, 23 May 2002 23:43 |
JoJo
Messages: 18 Registered: January 2002
|
Junior Member |
|
|
Hello all,may be you can help me:
The problem is that i have a "for each row" trigger,and i don t want him to fire for each row :),i want him to execute only when the row meet my needs,take an example: If first and second row are updated,the trigger fires and execute on first then second row,but if i want him to execute only on second row,what can i do?
If,for instance,the first row had a numcode = 0 and the second row have a numcode = 1,i thought i might put a statement,at the beginning, like (if :new.numcod <> 0 ) or FOR EACH ROW WHEN(new.numcode<>0) then "execution",but it doesn t work.The trigger stops firing.I don t know how to tell the trigger
to skip a row if it doesn t meet my needs.
Thanks.
|
|
|
Re: heu,trigger question [message #1717 is a reply to message #1716] |
Fri, 24 May 2002 00:21 |
John R
Messages: 156 Registered: March 2000
|
Senior Member |
|
|
A good way to do this is to put all the functionality of your trigger in a procedure, and change the trigger so that it will only call the prodcedure if the row meets you needs.
Eg
CREATE OR REPLACE TRIGGER my_trig
BEFORE INSERT ON my_table
FOR EACH ROW
AS
IF :new.numcode !=0 THEN
my_trig_code;
END IF;
END;
Where my_trig_code is a procedure containing the functionality that you want the trigger to perform.
This has several advantages
1) It keeps all the functionality of the system in the same place.
2) It makes the triggers much easier to read and understand.
|
|
|
Re: heu,trigger question [message #1722 is a reply to message #1717] |
Fri, 24 May 2002 03:36 |
JoJo
Messages: 18 Registered: January 2002
|
Junior Member |
|
|
Thanks john R,i ve tried and it didn t change anything.I can t understand what s happening.Maybe the database this company uses is corrupt or something,i ve search for null but there are none.
It's like the numcode is always equal to 0,but it s impossible,column are updated where numcod=0,=1,=2 etc...
Pffffff.....unbelievable.
Anyway,thanks for your help,if you've got another tip,let me know.
Take care.
|
|
|