oracle PL/SQL 中函数和过程的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8554860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:31:03  来源:igfitidea点击:

Difference between a function and a procedure in PL/SQL

oracleplsql

提问by ratsy

Possible Duplicate:
What is the difference between function and procedure in PL/SQL?

可能的重复:
PL/SQL 中的函数和过程有什么区别?

Functions always return a value, however when we use 'out' in a procedure that procedure also returns a value so please tell me when should we write a function and when should we write a procedure? What are the criteria on which we decide whether to use a procedure or a function?

函数总是返回一个值,但是当我们在过程中使用“out”时,该过程也会返回一个值,所以请告诉我什么时候应该写一个函数,什么时候应该写一个过程?我们决定使用过程还是函数的标准是什么?

回答by Rob van Laarhoven

Functions mostly do computations of some kind, and always return a value using the return statement, and can be used in a select statement. Procedures are used to implement business logic and canreturn one or more values using the out parameter(s). You should not do DML in functions.

函数主要进行某种计算,并且总是使用 return 语句返回一个值,并且可以在 select 语句中使用。过程用于实现业务逻辑,并且可以使用 out 参数返回一个或多个值。你不应该在函数中做 DML。