Subject | Re: multiple nested loops question |
---|---|
Author | donoghue_brendan |
Post date | 2005-03-11T00:26:38Z |
Thanks for your help.
Each loop is now terminated with an END and the query compiles just fine.
However when I run it I get a multiple rows in a singleton select. I
dont understand why I am getting this now. I thought that with only 1
suspend at the end the procedure would loop through then return a row
at a time to the client? What have I done wrong?
FOR SELECT
DISTINCT STUDENT_ID
FROM STUDENT_FORM_RUN
INTO :STU_STU_NUMBER
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 BEGIN
FOR SELECT
DISTINCT 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;
END
END
END!!
Thanks
Brendan
Each loop is now terminated with an END and the query compiles just fine.
However when I run it I get a multiple rows in a singleton select. I
dont understand why I am getting this now. I thought that with only 1
suspend at the end the procedure would loop through then return a row
at a time to the client? What have I done wrong?
FOR SELECT
DISTINCT STUDENT_ID
FROM STUDENT_FORM_RUN
INTO :STU_STU_NUMBER
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 BEGIN
FOR SELECT
DISTINCT 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;
END
END
END!!
Thanks
Brendan