DELIMITER $$
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `stock`.`log_delete`(vTableName VARCHAR(255), vTableId INT)
proc: BEGIN
/**
 * Processes orphan transactions.
 */
	IF vTableName NOT IN ('buy', 'sale', 'orderRow') THEN
		LEAVE proc;
	END IF;

	DELETE FROM inbound
		WHERE tableName = vTableName COLLATE utf8_general_ci
			AND tableId = vTableId;

	DELETE FROM outbound
		WHERE tableName = vTableName COLLATE utf8_general_ci
			AND tableId = vTableId;
END$$
DELIMITER ;
