Functions cannot be passed as objects
Jeffrey Kemp, April 23, 2016 - 11:44 pm UTC
I suspect the OP means to pass the function itself, a common technique in other languages like Javascript.
In PL/SQL, functions are not objects, and they cannot be passed as a parameter (e.g. to be executed by the called program). In the example above, the functions aren't passed - instead, they are executed once, in order, and the result is passed.
April 24, 2016 - 6:19 am UTC
Thanks for stopping by Jeff.
Cheers,
Connor
pass a function => pointer to function in C ??
david scott, April 25, 2016 - 8:05 pm UTC
I am wondering if the original questioner was looking for a way to use a function by supplying its name to a block, so that whenever the block was run next, it would do so with the name of a function provided, then invoke that function wherever needed in dynamic fashion. perhaps the matter could be restated as "is there a way to dereference other than a lengthy IF construct?"
IF inf_name = 'F1' THEN f1(some_args)
ELSIF inf_name = 'F2' then f2(some_args)
ELSE f3(some_args)
END IF;
I am personally unaware of either a method or a necessity for this ability, but would like the experts statement.
April 27, 2016 - 4:24 am UTC
It could all be done dynamically, ie,
execute immediate 'begin '||l_my_routine_name||'; end;'
but let me be clear - I think that's a really really bad idea!
Alternate Approach
Deb, October 11, 2016 - 8:55 pm UTC
One can pass functions as parameter to a function as using Types.