DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `sync_fl`()
BEGIN
DROP TABLE IF EXISTS `sh_prod_im__`;
ALTER TABLE `sh_prod_im` RENAME TO `sh_prod_im__`;
ALTER TABLE `sh_prod_im_` RENAME TO `sh_prod_im`;
END$$
DELIMITER ;
BEGIN TRANSACTION;
UPDATE `sh_prod_im` SET `updated` = 0;
INSERT
INTO `sh_prod_im` (`article`, ..., `updated`)
VALUES (:article, ..., 1)
ON DUPLICATE KEY UPDATE ..., `updated` = 1;
DELETE FROM `sh_prod_im` WHERE `updated` = 0;
COMMIT;