salix/db/routines/vn/procedures/entry_isEditable.sql

25 lines
562 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`entry_isEditable`(
vSelf INT
)
BEGIN
/**
* Comprueba si una entrada se puede actualizar
* si no se puede retorna un throw.
*
* @param vSelf Id de entrada
*/
DECLARE vIsEditable BOOL;
SELECT e.isBooked INTO vIsEditable
FROM `entry` e
JOIN entryType et ON et.code = e.typeFk
WHERE NOT et.isInformal
AND e.id = vSelf;
IF vIsEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
2024-07-05 07:59:15 +00:00
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
END IF;
END$$
DELIMITER ;