Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can Sub Procedure/Function Be Called Recursively
Can Sub Procedure/Function Be Called Recursively? - Oracle DBA FAQ - Creating Your Own PL/SQL Procedures and Functions
✍: FYIcenter.com
PL/SQL allows sub procedures or functions to be called recursively. The tutorial example below shows you how to calculate factorial values with a recursive sub function:
SQL> CREATE OR REPLACE PROCEDURE FACTORIAL_TEST AS 2 FUNCTION FACTORIAL(N NUMBER) 3 RETURN NUMBER AS 4 BEGIN 5 IF N <= 1 THEN 6 RETURN 1; 7 ELSE 8 RETURN N*FACTORIAL(N-1); 9 END IF; 10 END; 11 BEGIN 12 DBMS_OUTPUT.PUT_LINE('3! = ' || 13 TO_CHAR(FACTORIAL(3))); 14 DBMS_OUTPUT.PUT_LINE('10! = ' || 15 TO_CHAR(FACTORIAL(10))); 16 DBMS_OUTPUT.PUT_LINE('64! = ' || 17 TO_CHAR(FACTORIAL(64))); 18 END; 19 / SQL> EXECUTE FACTORIAL_TEST; 3! = 6 10! = 3628800 64! = 126886932185884164103433389335161480802000000000000...
There must be something wrong with the FACTORIAL() definition that causes those many extra '0's in the '64!' result.
2007-04-25, 6548👍, 0💬
Popular Posts:
What will be printed as the result of the operation below: main() { int a=0; if (a==0) printf("Cisco...
What is application domain? Explain. An application domain is the CLR equivalent of an operation sys...
.NET INTERVIEW QUESTIONS - What are types of compatibility in VB6? There are three possible project ...
If we have multiple AFTER Triggers on table how can we define the sequence of the triggers ? If a ta...
How Is the Width a Parent Element Related to Child Elements? - CSS Tutorials - Understanding Multipl...