0
我在MySQL中有2个存储过程。我想打电话从另一个但我需要一些帮助,语法MySql嵌套存储过程调用
下面是步骤1 FindPreviousDate
DELIMITER $$ CREATE PROCEDURE `FindPreviousDate`(IN eventdate DATETIME, IN lookbackDays INT, IN symbol VARCHAR(20))
BEGIN
SELECT *
FROM Price a
WHERE a.eventDate between (eventDate - interval lookbackDays day) and (eventdate - interval 1 day) and a.symbol = symbol
ORDER BY a.eventDate DESC
LIMIT 1;
END
下面是步骤2 FindCloseEvent
CREATE PROCEDURE `FindCloseEvent`(IN startdate DATETIME, IN enddate DATETIME,IN symbol VARCHAR(20), IN cutoff DOUBLE)
BEGIN
SELECT *
FROM Price a
WHERE a.eventDate between startdate and enddate and
(SELECT COUNT(*) from Price b where b.eventDate = a.eventDate and b.closePrice < cutoff and a.symbol = b.symbol and
(SELECT COUNT(*) from Price c where c.eventDate = (b.eventDate - interval 1 day) and c.closePrice >= cutoff and b.symbol = c.symbol));
END
我想将这段代码在程序2中使用程序1的结果
(b.eventDate - interval 1 day)
我需要获取帮助语法正确。我甚至不确定mySql是否允许我所要求的。
谢谢!