for each row, when??
Posted by: Jose Javier
Date: November 25, 2005 04:38PM
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.
i started working with triggers last week, heres the code that's bugging me:
CREATE TRIGGER llamada AFTER INSERT ON cdr
FOR EACH ROW
UPDATE rates SET prefix_r=-2 WHERE whereto_r="update";
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;
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.