Subject Re: [firebird-support] multiple nested loops question
Author Martijn Tonies
> Good Morning.

Evening... Or night, actually. :-)

> First of all thanks for all the help that this group, esp Helen, has
> given me over the past 2 weeks, you have made transition to firebird
> considerably less painfull for me than it could have been. :)
>
> But, I still have another question. I am unsure of the syntax to use
> for the following nested loops that I have in a stored procedure. This
> query returns multiple rows at each loop. I have tried adding a FOR
> SELECT at each loop but because I dont want to return the rows to the
> client with a SUSPEND I am unsure how to pass them to the next loop.
>
> Thanks
>
> Brendan
>
> FOR SELECT
> STUDENT_ID
> FROM STUDENT_FORM_RUN
> INTO :STU_STU_NUMBER
> DO SUSPEND

This will end the statement here -
"for select ... do ..."

If you want to make this a looper across the part below,
use:
DO BEGIN
> FOR SELECT
> STUDENT_ID, START_DATE, END_DATE
> FROM
> GET_FORM_DATES(:STU_STU_NUMBER)
> INTO
> :PROC_STUDENT_ID, :PROC_START_DATE, :PROC_END_DATE
> DO SUSPEND

Same here. I have no idea what the SUSPEND should do...

> FOR SELECT
> STU.STUDENT_ID, 'CURRENT_ENROLLMENT'
> FROM
> STU_ENROLMENT STU
> WHERE
> :PROC_STUDENT_ID = STU.STUDENT_ID
> AND :PROC_START_DATE < :DATE_TO
> AND :PROC_END_DATE > :DATE_TO
> AND STU.APP_CANCELLED IS NULL
> INTO :STUDENT_ID, :STATUS_TEXT
> DO SUSPEND;

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com