Subject | singleton select problem |
---|---|
Author | donoghue_brendan |
Post date | 2005-03-05T07:53:49Z |
Hello
I have written the below stored procedure. When I run the select by
itself I get 1 row returned. Yet when I compile and execute the
procedure I get thIS error :
SQL> EXECUTE PROCEDURE GET_FORM_DATES(399);
Statement failed, SQLCODE = -811
multiple rows in singleton select
Can anyone shed any light on why I am getting this error?
Thank you very much.
Brendan Donoghue
CREATE PROCEDURE GET_FORM_DATES (STUDENT_ID_IN INTEGER)
RETURNS (STUDENT_ID INTEGER, START_DATE DATE, END_DATE DATE)
-------------------------------------------------------------
-- THIS RETURNS THE STUDENTS TRUE START AND END DATE ---
-------------------------------------------------------------
AS
DECLARE VARIABLE SF_START_DATE DATE;
DECLARE VARIABLE TE_START_DATE DATE;
DECLARE VARIABLE SF_END_DATE DATE;
DECLARE VARIABLE TE_END_DATE DATE;
BEGIN
SELECT
MAX(TE.END_DATE), MIN(TE.START_DATE), MAX(SFR.START_DATE),
MIN(SFR.END_DATE), SFR.STUDENT_ID
FROM
STUDENT_FORM_RUN SFR,
FORM_RUN FR,
TERM TE
WHERE
SFR.STUDENT_ID = 399
AND SFR.FORM_RUN_ID = FR.FORM_RUN_ID
AND FR.TIMETABLE_ID = TE.TIMETABLE_ID
AND SFR.START_DATE IS NOT NULL
GROUP BY 5
INTO
:TE_END_DATE, :TE_START_DATE, :SF_START_DATE, :SF_END_DATE, :STUDENT_ID;
END_DATE = COALESCE(:SF_END_DATE, :TE_END_DATE);
START_DATE = COALESCE(:SF_START_DATE, :TE_START_DATE);
END!!
I have written the below stored procedure. When I run the select by
itself I get 1 row returned. Yet when I compile and execute the
procedure I get thIS error :
SQL> EXECUTE PROCEDURE GET_FORM_DATES(399);
Statement failed, SQLCODE = -811
multiple rows in singleton select
Can anyone shed any light on why I am getting this error?
Thank you very much.
Brendan Donoghue
CREATE PROCEDURE GET_FORM_DATES (STUDENT_ID_IN INTEGER)
RETURNS (STUDENT_ID INTEGER, START_DATE DATE, END_DATE DATE)
-------------------------------------------------------------
-- THIS RETURNS THE STUDENTS TRUE START AND END DATE ---
-------------------------------------------------------------
AS
DECLARE VARIABLE SF_START_DATE DATE;
DECLARE VARIABLE TE_START_DATE DATE;
DECLARE VARIABLE SF_END_DATE DATE;
DECLARE VARIABLE TE_END_DATE DATE;
BEGIN
SELECT
MAX(TE.END_DATE), MIN(TE.START_DATE), MAX(SFR.START_DATE),
MIN(SFR.END_DATE), SFR.STUDENT_ID
FROM
STUDENT_FORM_RUN SFR,
FORM_RUN FR,
TERM TE
WHERE
SFR.STUDENT_ID = 399
AND SFR.FORM_RUN_ID = FR.FORM_RUN_ID
AND FR.TIMETABLE_ID = TE.TIMETABLE_ID
AND SFR.START_DATE IS NOT NULL
GROUP BY 5
INTO
:TE_END_DATE, :TE_START_DATE, :SF_START_DATE, :SF_END_DATE, :STUDENT_ID;
END_DATE = COALESCE(:SF_END_DATE, :TE_END_DATE);
START_DATE = COALESCE(:SF_START_DATE, :TE_START_DATE);
END!!