Subject Re: [ib-support] Breaking out of For Select...Do
Author Helen Borrie
At 09:53 AM 6/05/2003 +0000, you wrote:
>I am writing my very first stored procedure, so please forgive my very
>newbie type questions.
>
>I'm doing a For Select...Do loop. There is a point in the loop where
>I will have reached a condition where I'm done with the loop (I don't
>want to even look at the rest of the rows returned from the Select).
>
>Is there a way to break out of the loop.
>
>Example:
>
>for select MY_NUM from MY_TABLE into :THIS_NUM
>do
> BEGIN
> THE_TOTAL = THE_TOTAL + THIS_NUM;
> if (THE_TOTAL >= 500) then
> /* somehow break out of the loop */
> END

Yup.

for select MY_NUM from MY_TABLE into :THIS_NUM
do
BEGIN
THE_TOTAL = 0;
WHILE (THE_TOTAL < 500) DO
BEGIN
THE_TOTAL = THE_TOTAL + THIS_NUM;
END
END

heLen