Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Recursive Function
Here is a recursive function that I wrote to find the grand-grand parent
value for the input I pass in the function.
However, when I call this function, it returns null all the time. What is strange is the DBMS_OUTPUT prints the value that I need.
Any comments/suggestions/pointers are most welcome.
CREATE OR REPLACE FUNCTION Recursive_function (p_parent IN NUMBER)
RETURN NUMBER
IS
v_parent NUMBER (5);
v_val NUMBER(5);
BEGIN
SELECT PARENT_ID=20
INTO v_parent FROM DSCR_CONTENT
IF v_parent IS NULL
THEN
DBMS_OUTPUT.PUT_LINE (To_char(P_parent)); RETURN (p_parent); ELSE v_val :=3D Recursive_function (v_parent);END IF;
![]() |
![]() |