Issue handling rows in trigger
The code below does not work. However if I add "limit 1" to the select statement at the top it works.
"SELECT id INTO rowNum FROM b04_reel_data limit 1;"
However then it only works for the first row.
Is there a way to fix this so that I can perform different actions depending on what row is updated?
I would really appreciate help with this!
-- Trigger DDL Statements
DELIMITER $$
USE `pgs`$$
CREATE
DEFINER=`root`@`localhost`
TRIGGER `pgs`.`main_logs`
BEFORE UPDATE ON `status`.`b04_reel_data`
FOR EACH ROW
BEGIN
DECLARE rowNum INTEGER;
SELECT id INTO rowNum FROM b04_reel_data;
CASE rowNum
WHEN 1 THEN
IF NEW.id=1 AND OLD.streamer_tension != NEW.streamer_tension THEN
INSERT INTO log_streamer_1 (streamer_tension) VALUES (NEW.streamer_tension) ;
WHEN 2 THEN
IF NEW.id=1 AND OLD.streamer_tension != NEW.streamer_tension THEN
INSERT INTO log_streamer_2 (streamer_tension) VALUES (NEW.streamer_tension) ;
WHEN 3 THEN
.....
END CASE;
END$$
Subject
Views
Written By
Posted
Issue handling rows in trigger
1978
February 24, 2012 05:09AM
1009
February 24, 2012 05:32AM
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.