Oracle/PLSQL: Execute a function that is defined in a package
Question: How can I execute a function that is defined in a package using Oracle/PLSQL?
Answer: 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.
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;
We can also execute a function by running an SQL statement. For example:
select package_name.function_name (15000) from dual;