如何使用參數“foo 表”執行 SP? (How to execute SP with arguments 'table of foo'?)


問題描述

如何使用參數“foo 表”執行 SP? (How to execute SP with arguments 'table of foo'?)

Using sqlplus how can I execute a stored procedure which has arguments which are 'table of foo' ?

So for instance in the following package how can I execute 'Get_AnnotationsForEmp' ?

create or replace PACKAGE "PKG_DROM"   as
    TYPE tblCostCentreIdentifier    IS TABLE OF BLA_COST_CENTRE.CCE_IDENTIFIER%TYPE INDEX BY BINARY_INTEGER;
    TYPE tblCCEAutoID       IS TABLE OF BLA_COST_CENTRE.CCE_AUTOID%TYPE INDEX BY BINARY_INTEGER;

    --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    --
    --++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    PROCEDURE Get_AnnotationsForEmp(
        EMP_EMPLOYEE_ID_IN      IN BLA_EMPLOYEE.EMP_EMPLOYEE_ID%TYPE,
        CCE_IDENTIFIER_OUT  OUT tblCostCentreIdentifier,
        CCE_AUTOID_OUT      OUT tblCCEAutoID);

    PROCEDURE Get_PastAnnotationsForEmp(
        EMP_EMPLOYEE_ID_IN      IN BLA_EMPLOYEE.EMP_EMPLOYEE_ID%TYPE,
        CCE_IDENTIFIER_OUT  OUT tblCostCentreIdentifier,
        CCE_AUTOID_OUT      OUT tblCCEAutoID);
END PKG_DROM;

If the procedure was in a package 'BAR' and looked like this ...

PROCEDURE FOO (ID IN NUMBER);

... then I know I could execute it like this :

declare
    r number;
begin
    r := BAR.FOO (1);
end;

but how can I extend that idea to accomomdate the OUT arguments which are 'table of' ?


參考解法

方法 1:

By declaring the variables using the package.type syntax:

DECLARE
  outTBL     PKG_DROM.tblCostCenereIdentifier;
  outAutoTBL PKG_DROM.tblCCEAutoID;
BEGIN
  PKG_DROM.GET_AnnotationsForEmp(id, outTBL, outAutoTBLZ);
END;

(by glauconThomas Jones-Low)

參考文件

  1. How to execute SP with arguments 'table of foo'? (CC BY-SA 3.0/4.0)

#plsql #arguments #oracle #stored-procedures #sqlplus






相關問題

RAISE_APPLICATION_ERROR 不返回消息 (RAISE_APPLICATION_ERROR doesn't return the message)

PL/SQL 塊和循環練習 (PL/SQL block and LOOP exercise)

如何從列中僅提取編號的行 (How to extract only numbered rows from a column)

如何編寫一個程序來自動執行一組查詢 (How to write a procedure to execute set of queries automatically)

使用 DBMS_OUTPUT.put_line 顯示錯誤消息 (Display error message using DBMS_OUTPUT.put_line)

如何編寫將Oracle數據庫表數據導出到excel文件的程序 (How to write a Procedure which exports Oracle database table data into excel file)

如何重載對像類型中的方法 (How to overload a method in an object type)

有沒有辦法以編程方式從 Oracle 包中提取表引用? (Is there a way to programmatically extract table references from an Oracle package?)

批量插入 Oracle 數據庫:哪個更好:FOR 游標循環還是簡單的選擇? (Bulk Insert into Oracle database: Which is better: FOR Cursor loop or a simple Select?)

如何使用參數“foo 表”執行 SP? (How to execute SP with arguments 'table of foo'?)

PL/SQL 我做錯了什麼? (PL/SQL What am I doing wrong?)

PL/SQL 顯示帶有條件的表中的數據 (PL/SQL Display Data From a Table with a Condition)







留言討論