MySQL help!! Need a solution to a trigger that is not working!?
-
Trying to run a trigger for a time function for a database class , keeps generating syntax errors and have been googling all day for a solution in the SQL manual. Help please! Delimiter $$ create trigger Late after insert on signinout For each row begin If each new.OutTime > 17:30 insert into transaction values (TransactionID, ((int(Time(OutTime)-17:30)/60)+1)*20), description, Date, Receipt, New.`StudentID`) end $$ Delimiter;
-
Answer:
I see a few errors, not sure if I caught them all though (this is untested). See 3 comments in code: Delimiter $$ create trigger Late after insert on signinout For each row begin If new.OutTime > 17:30 THEN -- Removed Each, added Then insert into transaction (TransactionID, ((int(Time(OutTime)-17:30)/60)+1)*20), description, Date, Receipt, New.`StudentID`); -- Add semicolon End If; -- Add End If end $$ Delimiter; The link below has a somewhat similar trigger. It might help you.
Eric at Yahoo! Answers Visit the source
Other answers
There are some errors in you code like End If & Then missing and each after the If clause. Delimiter // CREATE TRIGGER late AFTER INSERT ON signiout FOR EACH ROW BEGIN IF new.OutTime > 17:30 THEN INSERT INTO transaction VALUES (TransactionID, ((int(Time(OutTime)-17:30)/60)+1)*20), description, Date, Receipt, New.`StudentID`); END IF /* If Statement ends here */ END //
The Biker Boy
Related Q & A:
- Is it true that a permanent resident of the US doesn't need a visa for a short stay in Switzerland?Best solution by Yahoo! Answers
- I need a name for a company please.Best solution by Yahoo! Answers
- Do you need a permit for a car wash?Best solution by Yahoo! Answers
- I need a remote for a TV that's not manufactured any more.Best solution by Yahoo! Answers
- Can anyone help with a code for a ford fiesta radio?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.