salix/db/routines/vn/functions/ticketGetTotal.sql

32 lines
627 B
MySQL
Raw Normal View History

DELIMITER $$
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`ticketGetTotal`(vTicketId INT)
RETURNS decimal(10,2)
DETERMINISTIC
READS SQL DATA
BEGIN
/**
* Calcula el total con IVA de un ticket.
*
* @param vTicketId Identificador del ticket
* @return Total del ticket
*/
DECLARE vTotal DECIMAL(10,2);
DROP TEMPORARY TABLE IF EXISTS tmp.ticket;
CREATE TEMPORARY TABLE tmp.ticket
ENGINE = MEMORY
SELECT vTicketId ticketFk;
CALL ticketGetTotal(NULL);
SELECT total INTO vTotal FROM tmp.ticketTotal;
DROP TEMPORARY TABLE
tmp.ticket,
tmp.ticketTotal;
RETURN vTotal;
END$$
DELIMITER ;