MySQL Forums
Forum List  »  Triggers

Trigger to fire when condition met
Posted by: Joven Canezal
Date: August 18, 2016 08:10PM

Hello everyone, I need help with my trigger script. I need this to be executed only when condition is met,

To briefly explain,
I am currently making a c# application(Payroll system)
There is an attendance system which lets you time in and time out,
Since I created this trigger, My problem is that, whenever the employee click "time in" the trigger automatically executes where I still need the value of time out,

to make it short i need the trigger to execute only when the user has timein as well as time out,

Here is my script.
DELIMITER $$
CREATE TRIGGER `timeduration` AFTER INSERT ON `attendance` FOR EACH ROW
BEGIN
INSERT INTO time_sum SET EmployeeID = NEW.EmployeeID,Date = NEW.Date, duration = TIMEDIFF(NEW.TimeIN, NEW.TimeOUT);
END$$
DELIMITER ;

I'm kind of new to trigger so this might seem a noob question to you, but any help will be appreciated. thanks for your help!

Options: ReplyQuote


Subject
Views
Written By
Posted
Trigger to fire when condition met
1063
August 18, 2016 08:10PM
550
September 04, 2016 05:59AM
437
September 04, 2016 11:57AM


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.