When a function or procedure calls other ones, the creation order must be ascending, from the most sheltered function or procedure to which makes first call. But in recursivity case (routine which calls itself) it enters conflict, due to the referenced routine (which must exist), is the same one that makes the call.
Example of recursive function:
CREATE FUNCTION fibonacci (number integer)
NO EXTERNAL ACTION NOT DETERMINISTIC READS SQL DATA
IF number = 0 OR number = 1 THEN
RETURN fibonacci(number - 1) + fibonacci(number - 2);
Using dynamic call (with EXECUTE IMMEDIATE clause), function would be something like this:
SET m_call = 'CALL fibonacci (' || number || ')';
EXECUTE IMMEDIATE m_call;
Where m_call is a variable defined like char...
What about the return value? How would be exactly fibonnacci function with dynamic call?