MySQL Forums
Forum List  »  Triggers

Trigger - ERROR 1054: 1054: Unknown column
Posted by: Paolo Bertolini
Date: April 13, 2020 11:40AM

Good evening to everyone,

I have this error in a trigger of a table that insert or update a row in another table. It works well when insert a row in the other table. It goes wrong when update and get this error "ERROR 1054: 1054: Unknown column 'c0507_08_Qu' in 'field list'"

Segue listato del trigger.
Thank you


CREATE DEFINER=`root`@`localhost` TRIGGER `tb0503AFTER_INSERT` AFTER INSERT ON `tb0503_op_st` FOR EACH ROW BEGIN
DECLARE Numero INT(11);

SELECT COUNT(*) INTO Numero
FROM `test-import`.`tb0507_dep_tit`
WHERE `c0507_07_Str`=NEW.c0503_04_str;
IF Numero=0 THEN
INSERT INTO `test-import`.`tb0507_dep_tit`
(`c0507_07_Str`, c0507_08_Qu, c0507_09_Avg)
VALUES (NEW.`c0503_04_str`, NEW.c0503_08_QuOp, NEW.c0503_18_ValQu) ;
ELSE
SET @c08=`c0507_08_Qu` + NEW.c0503_08_QuOp;
UPDATE `test-import`.`tb0507_dep_tit`
SET `c0507_08_Qu` = @c08
WHERE `tb0507_dep_tit`.`c0507_07_Str` = NEW.`c0503_04_str`;
END IF;

END

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger - ERROR 1054: 1054: Unknown column
210
April 13, 2020 11:40AM


Sorry, only registered users may post in this forum.

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.