Somebody asked for a simple comparison between a PL/SQL
pass-by-value function and pass-by-reference procedure, where the
procedure uses only an OUT
mode parameter to return
the result. This provides examples of both, but please note that
a pass-by-value function can be used in SQL or PL/SQL context
while a pass-by-reference procedure can only be used in another
anonymous of named block PL/SQL program.
The function and procedure let you calculate the value of a number raised to a power of an exponent. The third parameter lets you convert the exponent value to an inverse value, like 2 to 1/2.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
CREATE OR REPLACE FUNCTION find_root_function ( pv_number BINARY_DOUBLE , pv_power BINARY_DOUBLE , pv_inverse BINARY_INTEGER DEFAULT 0 ) RETURN BINARY_DOUBLE IS -- Declare local variable for return value. … |