 DELIMITER $$


DROP TRIGGER IF EXISTS umowa_zlecenie_bd
$$ 
CREATE DEFINER = 'root'@'localhost' TRIGGER umowa_zlecenie_bd BEFORE DELETE ON umowa_zlecenie FOR EACH ROW 
A: BEGIN
	IF _TriggerDisabled() THEN LEAVE A; END IF;
	SET @session.trigger.umowa_zlecenie = TRUE;
	DELETE FROM  umowa_zlecenie_deleted WHERE GUID = OLD.GUID;
	INSERT IGNORE INTO umowa_zlecenie_deleted 
	SELECT * FROM umowa_zlecenie WHERE GUID = OLD.GUID;
	UPDATE umowa_zlecenie_deleted SET aLocaltime=now() WHERE GUID = OLD.GUID;
	SET @session.trigger.umowa_zlecenie = FALSE;
END;
$$