MySQL Forums
Forum List  »  Triggers

Re: Issues with converting update command to trigger
Posted by: Shawn Logan
Date: July 01, 2020 09:33AM

a few trigger attempts
_______________________________________

DROP IF EXISTS TRIGGER add_desc

DELIMITER $$

CREATE TRIGGER add_desc
BEFORE INSERT
ON telemetry_log FOR EACH ROW
BEGIN
INSERT device_desc INTO NEW.device_desc
FROM id_name_update;
END$$

DELIMITER ;


DROP IF EXISTS TRIGGER add_desc
DELIMITER //
CREATE TRIGGER add_desc BEFORE INSERT ON telemetry_log
BEGIN

INSERT device_desc INTO NEW.device_desc
From id_name_update
WHERE NEW.device_id = device_id;
END
//
DELIMITER ;


CREATE TRIGGER add_desc AFTER INSERT ON telemetry_log
BEGIN
UPDATE telemetry_log SET id_name_update ON telemetry_log.device_id = id_name_update.device_id SET telemetry_log.device_desc = id_name_update.device_desc WHERE telemetry_log.device_desc IS NULL";
END;

DROP IF EXISTS TRIGGER add_desc

DELIMITER $$

CREATE TRIGGER add_desc
before insert on telemetry_log

UPDATE telemetry_log
SET NEW.device_desc = id_name_update.device_desc
WHERE NEW.devie_desc IS NULL;

end;
$$
delimiter ;

DROP IF EXISTS TRIGGER add_desc

DELIMITER $$

CREATE TRIGGER add_desc
before insert on telemetry_log

UPDATE telemetry_log JOIN id_name_update ON telemetry_log.device_id = id_name_update.device_id
SET telemetry_log.device_desc = id_name_update.device_desc
WHERE telemetry_log.devie_desc IS NULL;

end;
$$
delimiter ;

Options: ReplyQuote




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.