MySQL Forums
Forum List  »  Triggers

Re: Issues with converting update command to trigger
Posted by: Shawn Logan
Date: July 02, 2020 05:55AM

I appreciate this community, thank you for this help. I am trying to watch table: telemetry_log for any insert. Upon any insert on telemetry_log i would like to update the column: device_desc of that newly inserted row with the device_desc from table: id_name_update based on matching device_ids.

Currently the command is running out of a bash script that uses the data remotely.

Here was my most recent attempt:

DROP IF EXISTS TRIGGER add_desc

DELIMITER $$

CREATE TRIGGER add_desc
AFTER insert on telemetry_log
FOR EACH ROW

BEGIN
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.