Link to home
Start Free TrialLog in
Avatar of Brogrim
BrogrimFlag for Ireland

asked on

MySQL After Upadte

I have written a trigger (with help from EE)
CREATE DEFINER=`root`@`%` TRIGGER trg_WalletIssue
    AFTER UPDATE ON tblpermit
    FOR EACH ROW 
	BEGIN
	IF New.CostWallet > 1 Then
    INSERT INTO tblservice_log
	
    SET      	DDAI_ServicesID = '4',
			id = New.id,
			UserID = (SELECT b.UserID FROM tblBatch b WHERE b.BatchID = New.PermitBatchID LIMIT 1),
			DDAI_Services_Date = NOW();
	END IF;
END

Open in new window


My problem is that if any part of the record is updated the trigger will execute, this is causing multiple records to be inserted into the service log.

How can I only execute the trigger only if the CostWallet changes and is >1
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brogrim

ASKER

Thanks