22 lines
552 B
MySQL
22 lines
552 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `stock`.`log_add`(IN `vTableName` VARCHAR(255), IN `vNewId` VARCHAR(255), IN `vOldId` VARCHAR(255))
|
||
|
proc: BEGIN
|
||
|
-- XXX: Disabled while testing
|
||
|
LEAVE proc;
|
||
|
|
||
|
IF vOldId IS NOT NULL AND !(vOldId <=> vNewId) THEN
|
||
|
INSERT IGNORE INTO `log` SET
|
||
|
tableName = vTableName,
|
||
|
tableId = vOldId,
|
||
|
operation = 'delete';
|
||
|
END IF;
|
||
|
|
||
|
IF vNewId IS NOT NULL THEN
|
||
|
INSERT IGNORE INTO `log` SET
|
||
|
tableName = vTableName,
|
||
|
tableId = vNewId,
|
||
|
operation = 'insert';
|
||
|
END IF;
|
||
|
END$$
|
||
|
DELIMITER ;
|