Subject Re: [firebird-support] What is wrong with this Stored Procedure?
Author Helen Borrie
At 08:46 AM 16/08/2004 +0000, you wrote:
>Hi,
>
>Can anybody tell me what is wrong with this Stored Procedure?
>
>It is supposed to return a path of the hierarchical data in the database.
>
>---------------------------------------------------
>
>SET TERM ^;
>
>CREATE PROCEDURE GET_ITEM_PATH(A_ITEM VARCHAR(39))
>RETURNS (ITEM_PATH VARCHAR(4000))
>AS
> DECLARE A_ITEM_PARENT VARCHAR(29);
>BEGIN
> IF (NOT (A_ITEM='ROOT')) THEN
> BEGIN
> SELECT ITEM_PARENT
> FROM ITEMS
> WHERE ITEM=:A_ITEM
> INTO :A_ITEM_PARENT;
>
> SUBNET_PATH_RES = GET_ITEM_PATH(A_ITEM_PARENT)||'/'||ITEM_PATH;
> END
>END
>
>----------------------------------------------------
>
>When I try to add the porocedure I get the error "Function unknown
>'GET_ITEM_PATH'. Are recursive procedure calls not allowed in Firebird
>or am I doing something wrong?

Yes, they are allowed, but stored procedures are not functions. You call
procedures with EXECUTE PROCEDURE (:PARAM) RETURNING_VALUES (:VARIABLE)

That will help solve the syntax. Your next problem will be the logic.

/heLen