[不指定 2010/01/09 07:05 | by 孤城浪子 ]
| |

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.

        

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;

          
        
        

Solution #2

        

We can also execute a function by running an SQL statement. For example:

        
          

select package_name.function_name (15000)
             from dual;

        
软件 | 评论(0) | 引用(0) | 阅读(5117)
 
发表评论
   
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]