Last answered:

21 Sept 2024

Posted on:

19 Sept 2024

0

MySql Triggers

I am using MySql Workbench 6.3 but while executing the Insert statement for dept_manager in After Trigger, MySql threw an error - Error Code: 1235 as shown in the below screenshot. 
If this version of MySql workbench doesn't support this multiple triggers for one table then what should I do? 
How should I update the Dept_manager table and Salaries table in After Trigger ?? 
Furthermore, just above that error(1235) is the Error Code 1452 which states - Can't add or update a child row : foreign key constraint fails. 
Kindly guide.Thanks. 
3 answers ( 0 marked as helpful)
Instructor
Posted on:

20 Sept 2024

0
Hi Mohammad!
Thanks for reaching out.
1) Can you please provide the screenshot for error 1235 you are referring to?
Otherwise, this error means that you already have an ALTER TRIGGER attached to the given table.
2) Regarding Error code 1452, please consult the following thread from the Q&A Section:
https://learn.365datascience.com/question/why-do-i-get-error-code-1452/
Thank you.
Looking forward to your answer.
Kind regards,
Martin
Posted on:

20 Sept 2024

0
Hi Martin. 
Thanks for your response. 
I actually took the screenshot but unfortunately forgot to upload it with my question. My apologies. 
So, here is the screenshot for Error Code - 1235. 
This occured when I tried to execute After Trigger, similar to how you execute it in the Lesson.
Instructor
Posted on:

21 Sept 2024

0
Hi Mohammad!
Thanks for providing a screenshot.
Please reboot workbench, set employees as a default database and then execute the query statement.
If the issue persists, please share the version of Workbench you are using - you may need to have to change it (although we've never encountered this error when executing the trigger queries).
Also, if the error persists, please do post the code itself apart from the screenshot - this will ensure we run at our end the exact same code as yourself when testing the issue.
Thank you very much.
Kind regards,
Martin

Submit an answer