简体   繁体   English

使用IF Logic调用存储过程中的存储过程

[英]Call Stored Procedures within a Stored Procedure with IF Logic

Unable to to call a stored procedure based on IF logic within a stored procedure. 无法在存储过程中基于IF逻辑调用存储过程。 I need to return the results of 1 of 2 stored procedures depending on the date of the month. 我需要根据月份的日期返回2个存储过程中的1个的结果。

The logic is improperly formatted and I do not know the correct way to format this for the desired results. 逻辑格式不正确,我不知道为所需结果格式化的正确方法。

Both procedures being called are just SELECT queries. 这两个过程都只是SELECT查询。

............................................ ............................................

DELIMITER //
CREATE PROCEDURE report_novea_remittance()
BEGIN

SELECT IF( DAYOFMONTH(CURDATE()) < 15,
           CALL report_novea_1st_15th(),
           CALL report_novea_16st_EOM());
       END 
DELIMITER ;

................................................ ................................................

IF day of month is greater than the 15th call report_novea_1st_15th() 如果一个月中的某天大于第15个通话,则report_novea_1st_15th()

IF false call CALL report_novea_16st_EOM() 如果错误呼叫CALL report_novea_16st_EOM()

That's not how you write an IF statement in a stored procedure. 这不是在存储过程中编写IF语句的方式。 The correct format is: 正确的格式是:

IF DAYOFMONTH(CURDATE()) < 15 THEN
    CALL report_novea_1st_15th();
ELSE
    CALL report_novea_16st_EOM();
END IF;

See the manual . 请参阅手册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM