IBM DB2从Compound SQL检索结果集

时间:2015-08-27 22:10:47

标签: db2 db2-luw db2-connect

我是DB2的新手,所以请原谅这对你来说太新手了。 我试图在Crystal Report中读取以下代码的输出 我得到了“没有数据可以检索”#39;我尝试将其映射到报表时出错。有没有回归'我在这里找不到数据集命令?

BEGIN Atomic
DECLARE m INT DEFAULT 6; --
WHILE m > 0 DO 
   Select Year(Current date - m Month) || '-' ||Month(Current date - m Month) AS Rpt_Month,Count(Ch.Caseid) As Outcome_Value from Case Ch Inner Join Status Cs on Ch.Caseid = Cs.CaseId Where Cs.Startdate <= (Select LAST_DAY(CURRENT_DATE - m MONTH) FROM SYSIBM.SYSDUMMY1) and (Cs.Enddate is null or Cs.Enddate > (Select LAST_DAY(CURRENT_DATE - m MONTH) FROM SYSIBM.SYSDUMMY1)); --
    SET m = m - 1;--
 END WHILE; -- END;

0 个答案:

没有答案