troubleshooting Question

Help me correcting Trigger in MySQL

Avatar of softbless
softbless asked on
DatabasesMySQL ServerSQL
6 Comments1 Solution341 ViewsLast Modified:
Hi Guys,

Plese correct this trigger. I wanna prevent insert in a table for some case.


DROP PROCEDURE IF EXISTS  prevent__insert_otherrole_rolesoc;

DELIMITER $$
CREATE TRIGGER prevent__insert_otherrole_rolesoc_edited
   BEFORE insert    ON acl_roles_users
   FOR EACH ROW
BEGIN
if EXISTS (select * from acl_roles_users where role_id='1196cdbd-ddd6-d49d-bf44-4c784fe3b3c7' and user_id=new.user_id)
   CALL get_last_custom_error_insert_otherrole_rolesoc();
END IF;
END$$
DELIMITER ;

DROP PROCEDURE IF EXISTS  prevent__insert_otherrole_rolesoc;

DELIMITER $$
CREATE TRIGGER prevent__insert_otherrole_rolesoc_edited
   BEFORE insert    ON acl_roles_users 
   FOR EACH ROW
BEGIN
if EXISTS (select * from acl_roles_users where role_id=new.role_id and user_id=new.user_id)
   CALL get_last_custom_error_insert_otherrole_rolesoc();
END IF;
END$$
DELIMITER ;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros