PL / SQL中的函数和过程有什么区别? [英] What is the difference between function and procedure in PL/SQL?
本文介绍了PL / SQL中的函数和过程有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在PL / SQL中,函数和过程有什么区别?
What is the difference between function and procedure in PL/SQL ?
推荐答案
过程没有返回值,而一个函数。
A procedure does not have a return value, whereas a function has.
示例:
Example:
CREATE OR REPLACE PROCEDURE my_proc
(p_name IN VARCHAR2 := 'John') as begin ... end
CREATE OR REPLACE FUNCTION my_func
(p_name IN VARCHAR2 := 'John') return varchar2 as begin ... end
注意函数在参数列表和作为关键字。这意味着它预计会在函数体内的最后一条语句读取如下内容:
Notice how the function has a return clause between the parameter list and the "as" keyword. This means that it is expected to have the last statement inside the body of the function read something like:
return(my_varchar2_local_variable);
其中my_varchar2_local_variable是应该由该函数返回的某个varchar2。
Where my_varchar2_local_variable is some varchar2 that should be returned by that function.
这篇关于PL / SQL中的函数和过程有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文