Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Recursive Function

Recursive Function

From: SRIDHARAN, SAN (SBCSI) <ss4569_at_sbc.com>
Date: Thu, 6 May 2004 16:19:48 -0700
Message-ID: <D363ADA29513DD4C879B4275920327DE0781D9@cafrfd1msgusr02.itservices.sbc.com>


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

    WHERE DSCR_CONTENT_ID =3D p_parent;

   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;
END Recursive_function;

Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--

Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
Received on Thu May 06 2004 - 18:17:05 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US