MySQL Forums
Forum List  »  Triggers

After Update Trigger if field = 1
Posted by: Poco Poco
Date: April 22, 2022 07:02AM

Needs Answer MySQL
1
Hi

I am hoping someone can help me out with a project I need to hand up. I need to design a basic DB with tables, data, queries, views, triggers etc. I am trying to create a trigger but it isn't working.

I have a transaction table called tblLoan and wanted an after update trigger on this table only if the late column = 1. The idea is the trigger would write the LoanID and MemebrID from tblLoan table into the tblLate table. My code is below, and I have tried different permutations of this.

SQL
delimiter //
CREATE TRIGGER Update_tblLoan_new
AFTER UPDATE
ON tblLoan FOR EACH ROW
BEGIN
IF (late = 1)
THEN
INSERT INTO tblLate (LoanID, MemberID ) VALUES (LoanID,MemberID);
END IF;
END; //

Error I get is below. Not 100% but it looke like my code it trying toSET the late value into my tblLoan table.

ERROR 1054: 1054: Unknown column 'late' in 'field list'
SQL Statement:


UPDATE `library`.`tblloan` SET `Late` = '1' WHERE (`LoanID` = '1')

Thanks in advance

Poco

Options: ReplyQuote


Subject
Views
Written By
Posted
After Update Trigger if field = 1
445
April 22, 2022 07:02AM


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.