CREATE DEFINER=`user`@`localhost` TRIGGER `dbname`.`after_delete_module` AFTER DELETE ON `dbname`.`fs_module` FOR EACH ROW BEGIN
DECLARE module_id_removed INT(11);
SELECT id_payment INTO module_id_removed FROM fs_opc_payment WHERE id_module = OLD.id_module;
DELETE FROM fs_opc_payment WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_lang WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_shop WHERE id_payment = module_id_removed;
END
The part about the definer gets nicely treated by the exporter, and get's rid of it when skip-definers is set to true.
The issue comes with the part calling 'dbname'.
When trying to import the file on another database, if the name of the database is not the same, the trigger can't be created.
That's that the exporter has swote in sql file:
DROP TRIGGER IF EXISTS `after_delete_module`;
DELIMITER ;;
/*!50003 CREATE*/ /*!50003 TRIGGER `dbname`.`after_delete_module` AFTER DELETE ON `dbname`.`fs_module` FOR EACH ROW BEGIN
DECLARE module_id_removed INT(11);
SELECT id_payment INTO module_id_removed FROM fs_opc_payment WHERE id_module = OLD.id_module;
DELETE FROM fs_opc_payment WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_lang WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_shop WHERE id_payment = module_id_removed;
END */;;
DELIMITER ;
Any chances to improvement?
Something like this will import nicely -it has been tested-:
DROP TRIGGER IF EXISTS `after_delete_module`;
DELIMITER ;;
/*!50003 CREATE*/ /*!50003 TRIGGER `after_delete_module` AFTER DELETE ON `fs_module` FOR EACH ROW BEGIN
DECLARE module_id_removed INT(11);
SELECT id_payment INTO module_id_removed FROM fs_opc_payment WHERE id_module = OLD.id_module;
DELETE FROM fs_opc_payment WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_lang WHERE id_payment = module_id_removed;
DELETE FROM fs_opc_payment_shop WHERE id_payment = module_id_removed;
END */;;
DELIMITER ;
Hi, as far as I tested, omitting database name will lead to the creation of
a trigger that will match all tables ignoring in which dB they are. I'm not
sure that this will work as you want.
Triggers are listed with subsequent command:
I give you the output of a statement creation:
The part about the definer gets nicely treated by the exporter, and get's rid of it when skip-definers is set to true.
The issue comes with the part calling 'dbname'. When trying to import the file on another database, if the name of the database is not the same, the trigger can't be created.
That's that the exporter has swote in sql file:
Any chances to improvement? Something like this will import nicely -it has been tested-: