21 lines
416 B
SQL
21 lines
416 B
SQL
DELIMITER $$
|
|
CREATE OR REPLACE DEFINER=`vn-admin`@`localhost` FUNCTION `vn`.`currentRate`(vCurrencyFk INT, vDated DATE)
|
|
RETURNS decimal(10,4)
|
|
NOT DETERMINISTIC
|
|
READS SQL DATA
|
|
BEGIN
|
|
|
|
DECLARE curRate DECIMAL(10,4);
|
|
|
|
SELECT value INTO curRate
|
|
FROM referenceRate
|
|
WHERE dated <= vDated
|
|
AND currencyFk = vCurrencyFk
|
|
ORDER BY dated DESC
|
|
LIMIT 1;
|
|
|
|
RETURN curRate;
|
|
|
|
END$$
|
|
DELIMITER ;
|