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

18 lines
352 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT)
proc: BEGIN
/**
* Updates the number of entries assigned to the travel.
*
* @param vSelf The travel id
*/
UPDATE travel
SET totalEntries = (
SELECT COUNT(id)
FROM entry
WHERE travelFk = vSelf
)
WHERE id = vSelf;
END$$
DELIMITER ;