MYSQL错误:PROCEDURE无法在给定的上下文中返回结果集

时间:2010-07-23 11:43:25

标签: mysql stored-procedures mysql-error-1312

我是mysql中存储过程的新手

这是返回不包括Weekends的日期差异的过程,但它返回错误

#1312 - PROCEDURE blog1.DayCount can't return a result set in the given context

这是程序

DROP PROCEDURE IF EXISTS daycount; 
CREATE PROCEDURE DayCount( d1 DATE, d2 DATE ) 
SELECT dd.iDiff, dd.iDiff - dd.iWeekEndDays AS iWorkDays, dd.iWeekEndDays 
FROM ( 
  SELECT 
    dd.iDiff, 
    ((dd.iWeeks * 2) +  
    IF(dd.iSatDiff >= 0 AND dd.iSatDiff < dd.iDays, 1, 0) +  
    IF (dd.iSunDiff >= 0 AND dd.iSunDiff < dd.iDays, 1, 0)) AS iWeekEndDays 
  FROM ( 
    SELECT 
      dd.iDiff, 
      FLOOR(dd.iDiff / 7) AS iWeeks, 
      dd.iDiff % 7 iDays, 
      5 - dd.iStartDay AS iSatDiff, 
      6 - dd.iStartDay AS iSunDiff 
    FROM ( 
      SELECT 
        1 + DATEDIFF(d2, d1) AS iDiff, 
        WEEKDAY(d1) AS iStartDay 
      ) AS dd 
  ) AS dd 
) AS dd ; 


CALL DayCount( '2009-8-1','2009-9-15'); 

1 个答案:

答案 0 :(得分:0)

在mysql控制台中检查这个存储过程,如果它工作正常,你应该从PHP检查你的调用。 我发现same problem is happen with other people