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

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

Re: Recursive Function

From: Juan Cachito Reyes Pacheco <jreyes_at_dazasoftware.com>
Date: Thu, 6 May 2004 19:35:29 -0400
Message-ID: <013601c433c2$dd3c8720$2501a8c0@dazasoftware.com>


Hi Sridharan if you accept a suggestion, as I understand it is so

  1. put the return at the end, not conditional, is better to have only one return
  2. I think you forgot the loop

CREATE OR REPLACE FUNCTION Recursive_function (p_parent IN NUMBER)

   RETURN NUMBER
IS

   v_parent NUMBER (5);
   v_val NUMBER(5);
BEGIN while true loop

   SELECT PARENT_ID=20

     INTO v_parent
     FROM DSCR_CONTENT

    WHERE DSCR_CONTENT_ID = p_parent;

   IF v_parent IS NULL THEN

      exit;
   ELSE
      p_parent :=3D Recursive_function (p_parent);    END IF;
end loop;

 RETURN (p_parent);
END Recursive_function;

Juan Carlos Reyes Pacheco
OCP
Database 9.2 Standard Edition



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:37:04 CDT

Original text of this message

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