【问题标题】:Send multidimensional array as out parameter using Oracle stored procedure使用 Oracle 存储过程发送多维数组作为输出参数
【发布时间】:2013-07-08 03:50:03
【问题描述】:

请在这件事上帮助我,

  1. 我们能否在 Oracle 存储过程中创建多维数组?如果可以,可以举个例子吗?

  2. 我们能否从 Oracle 存储过程中发送包的 as out 参数?

请帮帮我。

谢谢你, 香菜

【问题讨论】:

    标签: database oracle stored-procedures parameters out


    【解决方案1】:
    /* Package header */
    CREATE OR REPLACE PACKAGE exmaple_pkg AS 
    
        TYPE example_rec IS RECORD(col1 NUMBER, col2 NUMBER );
    
        TYPE example_ntt IS TABLE OF example_rec;
    
        PROCEDURE example_proc(parameter_out OUT example_ntt);
    
    END exmaple_pkg;
    
    /* Package body */
    CREATE OR REPLACE PACKAGE BODY exmaple_pkg AS 
    
        PROCEDURE example_proc(parameter_out OUT example_ntt)
        AS
        BEGIN
            parameter_out := example_ntt();
            parameter_out.EXTEND;
            parameter_out(1).col1 := 11;
            parameter_out(1).col2 := 22;
        END example_proc;
    
    END exmaple_pkg;
    
    /* Call the procedure */
    DECLARE
        l_variable exmaple_pkg.example_ntt;
    BEGIN
        exmaple_pkg.example_proc(l_variable);
    
        DBMS_OUTPUT.PUT_LINE('col1:' || l_variable(1).col1);
        DBMS_OUTPUT.PUT_LINE('col2:' || l_variable(1).col2);
    END;
    
    /* The result */
    col1:11
    col2:22
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-12
      • 2013-10-08
      • 1970-01-01
      • 2012-11-23
      相关资源
      最近更新 更多