Saturday, September 13, 2014

How can I execute a function that is defined in a package using Oracle/PLSQL?

To execute a function that is defined in a package, you'll have to prefix the function name with the package name.

package_name.function_name (parameter1, parameter2, ... parameter_n)
You can execute a function a few different ways.

SOLUTION #1

First, we'll take a look at how to execute a function using a test block. Below we've declared a variable called result that is a number. We've passed in a value of 15000 into the function and the result of the function will be returned to the variable called result.

declare
   result number;
begin
   -- Call the function
   result := package_name.function_name (15000);
end;

No comments:

Post a Comment