0

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;
Abey
  • 155
  • 1
  • 2
  • 9
  • This code fragment would produce a DB2 syntax error. You must `SELECT` `INTO` something in SQL PL. Is this the entire code or a fragment? – mustaccio Aug 27 '15 at 22:30
  • This is entire code and it does not give a syntax error on testing. Generates message - DB20000I The SQL command completed successfully. No data is displayed though – Abey Aug 27 '15 at 22:34

0 Answers0