Subject | Re: [firebird-support] Looping a Stored Procedure - Email found in subject |
---|---|
Author | Michael Ludwig |
Post date | 2010-05-26T23:50:02Z |
Leyne, Sean schrieb am 26.05.2010 um 17:41:17 (-0400):
and thus feed the loop. But you've probably guessed right ...
Michael Ludwig
> > FOR SELECT STARTRECEIPT,ENDRECEIPT, [...]Might also be what the OP wants, as ZOUTPERIOD may return multiple rows
> > FROM ZOUTPERIOD(:REPORTSTARTDATE,:REPORTENDDATE)
> > WHERE :REPORTSTARTDATE <= :ENDDATE
> > INTO :STARTRECEIPT,:ENDRECEIPT, [...]
> > DO
> > BEGIN
> > REPORTSTARTDATE = REPORTSTARTDATE + 1;
> > REPORTENDDATE = REPORTSTARTDATE + 1;
> > SUSPEND;
> > END
> > END
>
> You don't have the ZOUTPERIOD in a loop. The ZOUTPERIOD SP will only
> be called once, with the initial parameter values.
and thus feed the loop. But you've probably guessed right ...
> You need to use the following approach:--
>
> ...
> WHILE (ReportEndDate <= EndDate) DO
> BEGIN
> FOR SELECT ....
> INTO ....
> DO
> BEGIN
> SUSPEND;
> REPORTSTARTDATE = REPORTSTARTDATE + 1;
> REPORTENDDATE = REPORTSTARTDATE + 1;
> END
> END
> ...
>
>
> Sean
Michael Ludwig