1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
SET TERM ^ ;
CREATE PROCEDURE GET_USER_MSG (
ASUBSTITUTE_ID INTEGER,
ADEPTH INTEGER)
RETURNS (
AUSER_ID INTEGER)
AS
DECLARE VARIABLE TMP_USER_ID INTEGER;
begin
FOR SELECT
USER_ID
FROM
USER
WHERE
SUBSTITUTE_ID =:ASUBSTITUTE_ID
AND
USER_SUBSTITUTE_ENABLED = 1
INTO
TMP_USER_ID
DO
BEGIN
IF (DEPTH > -1) then
BEGIN
/* parcours récursif */
SELECT AUSER_ID FROM GET_USER_MSG (TMP_USER_ID, :DEPTH-1) INTO :AUSER_ID;
suspend;
END
ELSE
BEGIN
/* affectation de la variable qui sera retournée */
AUSER_ID = :TMP_USER_ID;
suspend;
END
END
end^
SET TERM ; ^ |
Partager