It seems not so accurate
Shyamal, October 24, 2020 - 2:51 am UTC
I have one doubt here..! I feel you have just called the function using for loop, But how can we say It is recursive ? The function should call its own function again (Function calls itself) is said to be recursive right ??? I am confused.
October 27, 2020 - 1:40 am UTC
To *test* the function, I called it in a loop.
But look *inside* the function code. It calls itself.
do not do this
marc, October 30, 2020 - 7:03 pm UTC
Do not call the function on the very 1st line, a few years ago i accidently did not realize i placed the function in the 1st line and the DB server crashed. If i have any code before it, oracle caught the issue, like null; and oracle did not crash.
CREATE OR REPLACE FUNCTION factorial(n POSITIVE)
RETURN POSITIVE IS
BEGIN
factorial(n - 1);
IF n = 1 THEN
RETURN n;
ELSE
RETURN n * factorial(n - 1);
END IF;
END;
/
opps
November 02, 2020 - 2:43 am UTC
Yes, that's got endless loop and a lot of memory consumption written all over it :-)