27 lines
622 B
SQL
27 lines
622 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`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 vIsNotEditable BOOL DEFAULT FALSE;
|
|
|
|
SELECT TRUE INTO vIsNotEditable
|
|
FROM `entry` e
|
|
LEFT JOIN entryType et ON et.code = e.typeFk
|
|
WHERE e.id = vSelf
|
|
AND e.isBooked
|
|
AND (e.typeFk IS NULL OR NOT et.isInformal);
|
|
|
|
IF vIsNotEditable AND NOT IFNULL(@isModeInventory, FALSE) THEN
|
|
CALL util.throw(CONCAT('Entry ', vSelf, ' is not editable'));
|
|
END IF;
|
|
|
|
END$$
|
|
DELIMITER ;
|