21 lines
515 B
SQL
21 lines
515 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`root`@`localhost` FUNCTION `vn`.`getSpecialPrice`(vItemFk int(11),vClientFk int(11))
|
|
RETURNS decimal(10,2)
|
|
NOT DETERMINISTIC
|
|
READS SQL DATA
|
|
BEGIN
|
|
DECLARE price DECIMAL(10,2);
|
|
|
|
SELECT rate3 INTO price
|
|
FROM vn.priceFixed
|
|
WHERE itemFk = vItemFk
|
|
AND util.VN_CURDATE() BETWEEN started AND ended ORDER BY created DESC LIMIT 1;
|
|
|
|
SELECT `value` INTO price
|
|
FROM vn.specialPrice
|
|
WHERE itemFk = vItemFk
|
|
AND clientFk = vClientFk ;
|
|
RETURN price;
|
|
END$$
|
|
DELIMITER ;
|