Skip navigation links

MySQL Forums :: Triggers :: for each row, when??


Advanced Search

for each row, when??
Posted by: Jose Javier ()
Date: November 25, 2005 04:38PM

hey there!
i got this trigger who has to insert a value in table temp whenever cdr is modified. If i dont place "DISTINCT" on the statement (see below) the values get copied as many times as there are rows on cdr.
However, i got a counter inside the trigger, @i, which should, at the end of the trigger, have the same value as the amount of rows on the trigger. but it doesnt. it ends with 1 (starting on 0). i got another counter on the procedure called rater(), which also only gets its value rased by 1.
any thoughts?

i started working with triggers last week, heres the code that's bugging me:

DELIMITER $
CREATE TRIGGER llamada AFTER INSERT ON cdr
FOR EACH ROW
BEGIN
SET @h:=@h+1;
UPDATE rates SET prefix_r=-2 WHERE whereto_r="update";
CALL rater();
DELETE FROM temp;
INSERT INTO temp (src_t,dst_t,billsec_t,sizepref_t) SELECT DISTINCT new.src, CAST(new.dst AS decimal), new.billsec, 0 FROM cdr WHERE (new.src="200" OR new.src="201" OR new.src="202" OR new.src="207") AND new.billsec>=2;
END $
DELIMITER ;

Options: ReplyQuote


Subject Views Written By Posted
for each row, when?? 11694 Jose Javier 11/25/2005 04:38PM
Re: for each row, when?? 2720 Thomas CORBIERE 11/28/2005 04:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.