PL/SQL中确切的IN,OUT,IN OUT参数是什么

编程入门 行业动态 更新时间:2024-10-27 18:19:11
本文介绍了PL/SQL中确切的IN,OUT,IN OUT参数是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在这里查找问题以及在网上查找和观看视频,但我仍然对输入,输出到底是什么感到困惑.我问的原因是因为我正在编写一个过程,该过程将基于其他过程中的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:

参数的模式指示参数是将数据传递到过程(IN),从过程返回数据(OUT),还是可以同时执行两个操作(IN OUT).

The mode of a parameter indicates whether the parameter passes data to a procedure (IN), returns data from a procedure (OUT), or can do both (IN OUT).

还有关于OUT参数的具体信息:

And about OUT parameters specifically:

...您不能使用它将值传递给过程.即使已为它分配了值,也无法在过程中读取它的值.

... you cannot use it to pass a value to the procedure. Nor can you read its value inside the procedure, even after a value has been assigned to it.

编辑

实际上,尽管上面提供的信息是有效的,但我链接到的资源很贫乏(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:

  • 默认模式

    • Default 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:

      • 必须指定.

        • Must be specified.

          将值返回给调用者.

          形式参数被初始化为其类型的默认值.该类型的默认值是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:

          • 必须指定.

            • Must be specified.

              将初始值传递给子程序,并将更新后的值返回给调用者.

              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参数是什么

本文发布于:2023-07-22 13:35:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1187962.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:确切   参数   PL   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!