32 lines
626 B
SQL
32 lines
626 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` FUNCTION `vn`.`buy_getUltimate`(
|
|
vItemFk INT,
|
|
vWarehouseFk INT,
|
|
vDated DATE
|
|
)
|
|
RETURNS int(11)
|
|
DETERMINISTIC
|
|
BEGIN
|
|
/**
|
|
* Calcula las últimas compras realizadas hasta una fecha.
|
|
*
|
|
* @param vItemFk Id del artículo
|
|
* @param vWarehouseFk Id del almacén
|
|
* @param vDated Compras hasta fecha
|
|
* @return Id de compra
|
|
*/
|
|
DECLARE vBuyFk INT;
|
|
|
|
CALL buy_getUltimate(vItemFk, vWarehouseFk, vDated);
|
|
|
|
SELECT buyFk INTO vBuyFk
|
|
FROM tmp.buyUltimate;
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS
|
|
tmp.buyUltimate,
|
|
tmp.buyUltimateFromInterval;
|
|
|
|
RETURN vBuyFk;
|
|
END$$
|
|
DELIMITER ;
|