salix/db/routines/hedera/procedures/image_unref.sql

18 lines
421 B
MySQL
Raw Permalink Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `hedera`.`image_unref`(
vCollection VARCHAR(255),
vName VARCHAR(255)
)
BEGIN
/**
* Decreases the reference count of an image.
*
* @param vCollection The collection name
* @param vName The image name
*/
UPDATE image SET nRefs = GREATEST(CAST(nRefs AS SIGNED) - 1, 0)
WHERE `name` = vName
AND collectionFk = vCollection;
END$$
DELIMITER ;