Can you help me trying to combine multiple triggers into one?

What I have so far throws a: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''unit_of_measure'='%') or I have tried adding declares DECLARE val_cal INT(11); DECLARE value CHAR(50); DECLARE unit_of_measure CHAR(1);

Here's what i have:

delimiter $$ CREATE TRIGGER `do_all` BEFORE INSERT ON `telemetry_log` FOR EACH ROW Begin SET new.device_desc = ( select device_desc from id_name_update where device_id=new.device_id ); IF (NEW'.unit_of_measure'='%') THEN SET new.val_cal = ( select hum_cal from id_name_update where device_id=new.device_id); ELSEIF (NEW.'unit_of_measure'='F') SET new.val_cal = ( select temp_cal from id_name_update where device_id=new.device_id); END IF; SET new.value = new.value + new.val_cal; END$$ DELIMITER ;


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.