Как объединить эти две процедуры выбора firebird, используя эту переменную REFERENCE через if, case или другой метод. Если REFERENCE = 1, то отображается процедура 1, если REFERENCE = 2, отображается процедура 2. Я пытаюсь получить 1 процедуру выбора с условиями, а не 2 процедуры.
CREATE PROCEDURE PRINT_NON_REF1(
M VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
Y VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
REFERENCE VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1)
RETURNS(
AP_PSTIONLVL_NON VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
AP_POSTION_NON VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
RANKING_MONTH VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
RANKING_YEAR VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1)
AS
BEGIN
FOR
SELECT
'',
'',
RANKING_MONTH,
RANKING_YEAR
FROM APPLICANT
WHERE RANKING_MONTH = :M AND RANKING_YEAR = :Y
GROUP BY
RANKING_MONTH,
RANKING_YEAR
INTO
:AP_PSTIONLVL_NON,
:AP_POSTION_NON,
:RANKING_MONTH,
:RANKING_YEAR
DO
BEGIN
SUSPEND;
END
END;
и
CREATE PROCEDURE PRINT_NON_REF2(
M VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
Y VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
REFERENCE VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1)
RETURNS(
AP_PSTIONLVL_NON VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
AP_POSTION_NON VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
RANKING_MONTH VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1,
RANKING_YEAR VARCHAR(50) CHARACTER SET ISO8859_1 COLLATE ISO8859_1)
AS
BEGIN
FOR
SELECT
AP_PSTIONLVL_NON,
AP_POSTION_NON,
RANKING_MONTH,
RANKING_YEAR
FROM APPLICANT
WHERE RANKING_MONTH = :M AND RANKING_YEAR = :Y
GROUP BY
AP_PSTIONLVL_NON,
AP_POSTION_NON,
RANKING_MONTH,
RANKING_YEAR
INTO
:AP_PSTIONLVL_NON,
:AP_POSTION_NON,
:RANKING_MONTH,
:RANKING_YEAR
DO
BEGIN
SUSPEND;
END
END;