问题描述
我在这里查找问题以及在网上查找和观看视频,但我仍然对输入,输出到底是什么感到困惑.我问的原因是因为我正在编写一个过程,该过程将基于其他过程中的IN参数记录错误,
I've looked up questions here as well as looking online and watching videos but I'm still confused exactly what IN, OUT is. The reason I'm asking is because I'm writing a procedure that will log an error based on the IN parameters in other procedures,
干杯!
推荐答案
Oracle文档此处很好地解释了:
The Oracle documentation here does a good job of explaining:
还有关于OUT
参数的具体信息:
And about OUT
parameters specifically:
编辑
实际上,尽管上面提供的信息是有效的,但我链接到的资源很贫乏(Ada程序员指南的SQL *模块).
Actually, though the information provided above is valid, I linked to a poor resource (SQL*Module for Ada Programmer's Guide).
可以在这里找到更好,更完整的资源来更好地理解这三种模式:表8-1 PL/SQL子程序参数模式.
A much better and more complete resource to better understand the 3 modes can be found here: Table 8-1 PL/SQL Subprogram Parameter Modes.
IN
模式:
IN
mode:
将值传递给子程序.
形式参数的作用类似于常量:子程序开始时,其值为其实际参数或默认值,并且子程序无法更改该值.
Formal parameter acts like a constant: When the subprogram begins, its value is that of either its actual parameter or default value, and the subprogram cannot change this value.
实际参数可以是常量,初始化变量,文字或表达式.
Actual parameter can be a constant, initialized variable, literal, or expression.
实际参数是通过引用传递的.
Actual parameter is passed by reference.
OUT
模式:
OUT
mode:
将值返回给调用者.
形式参数被初始化为其类型的默认值.该类型的默认值是NULL
,除了具有非NULL
默认值的记录类型.
Formal parameter is initialized to the default value of its type. The default value of the type is NULL
except for a record type with a non-NULL
default value.
当子程序开始时,形式参数具有其初始值,而不管其实际参数的值如何. Oracle建议子程序为形式参数分配一个值.
When the subprogram begins, the formal parameter has its initial value regardless of the value of its actual parameter. Oracle recommends that the subprogram assign a value to the formal parameter.
如果形式参数类型的默认值为NULL
,则实际参数必须是数据类型未定义为NOT NULL
的变量.
If the default value of the formal parameter type is NULL
, then the actual parameter must be a variable whose data type is not defined as NOT NULL
.
默认情况下,实际参数按值传递;如果指定NOCOPY
,则可能通过引用传递.
By default, actual parameter is passed by value; if you specify NOCOPY
, it might be passed by reference.
IN OUT
模式:
IN OUT
mode:
将初始值传递给子程序,并将更新后的值返回给调用者.
Passes an initial value to the subprogram and returns an updated value to the invoker.
形式参数的作用类似于初始化变量:子程序开始时,其值就是其实际参数的值. Oracle建议子程序更新其值.
Formal parameter acts like an initialized variable: When the subprogram begins, its value is that of its actual parameter. Oracle recommends that the subprogram update its value.
实际参数必须是变量(通常是字符串缓冲区或数字累加器).
Actual parameter must be a variable (typically, it is a string buffer or numeric accumulator).
默认情况下,实际参数按值传递(双向);如果指定NOCOPY
,则可能通过引用传递.
By default, actual parameter is passed by value (in both directions); if you specify NOCOPY
, it might be passed by reference.
这篇关于PL/SQL中确切的IN,OUT,IN OUT参数是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!