I am new to DB2, so please excuse if this seems too novice to you. I am trying to read the output of the following code in a Crystal Report I get 'No Data to Retrieve' error when I try to map it to the report. Is there a 'RETURN' dataset command I am missing here?
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;