2010-07-23 31 views
4

我在mysql中是新的存儲過程的結果集MYSQL錯誤:過程不能返回在給定上下文

這是返回不包括週末日期差異的程序,但它返回錯誤

#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'); 
+0

你打這個程序怎麼樣?這是一個API的問題。 – Naktibalda 2010-07-23 12:39:40

+0

沒有使用API​​。我創建並使用php函數調用PROCEDURE – sathish 2010-07-24 04:31:25

回答