January 2012
Intermediate to advanced
542 pages
11h 28m
English
In this recipe, we will investigate the use of recursive PL/SQL functions and their impact on performance.
The following steps demonstrate recursive functions:
SH schema:
CONNECT sh@TESTDB/sh
FACTORIAL_RECURSIVE function to calculate the factorial of a given number (which is the product of all positive integers less than or equal to the given number) using the well-known recursive algorithm, as follows:CREATE OR REPLACE FUNCTION FACTORIAL_RECURSIVE (ANUM NUMBER) RETURN NUMBER IS AVALUE NUMBER; BEGIN IF ANUM <= 1 THEN AVALUE := 1; ELSE AVALUE := ANUM * FACTORIAL_RECURSIVE(ANUM - 1); END IF; RETURN AVALUE; END;
FACTORIAL_ITERATIVE to calculate the factorial of ...Read now
Unlock full access