如何运行此存储过程

时间:2011-07-20 22:04:44

标签: oracle stored-procedures plsql

我必须检查此程序

我将以下值作为参数

34220, 2815,'7/20/2011', 32760, 100, 'PMNT_CHECK', 1, null, "", false, null, null

DECLARE
  P_APP_ID NUMBER;
  P_USER_ID NUMBER;
  P_DATE DATE;
  P_INV_IDS WB_PROD.WB_PCK_TYPES.T_IDS;
  P_AMNTS WB_PROD.WB_PCK_TYPES.T_NUMBERS;
  P_PMNT_METHOD VARCHAR2(15);
  P_BANK_AC_FROM NUMBER;
  P_CHECK_NUMBERS WB_PROD.WB_PCK_TYPES.T_NUMBERS;
  P_MEMO VARCHAR2(1000);
  P_PAY_MULTIPLE NUMBER;
  P_CRD_IDS WB_PROD.WB_PCK_TYPES.T_IDS;
  P_CRD_AMOUNTS WB_PROD.WB_PCK_TYPES.T_PRICES;
  O_PY_ID NUMBER;
BEGIN
  P_APP_ID := 34220;
  P_USER_ID := 2815;
  P_DATE := '7/20/2011';
  -- Modify the code to initialize the variable
  P_INV_IDS := 32760;
  -- Modify the code to initialize the variable
  P_AMNTS := 100;
  P_PMNT_METHOD := 'PMNT_CHECK';
  P_BANK_AC_FROM := 1;
  -- Modify the code to initialize the variable
 --P_CHECK_NUMBERS := NULL;
  P_MEMO := '';
  P_PAY_MULTIPLE := false;
  -- Modify the code to initialize the variable
  -- P_CRD_IDS := NULL;
  -- Modify the code to initialize the variable
  -- P_CRD_AMOUNTS := NULL;

  WB_PCK_BILL_PAYMENTS.PAY_BILLS(
    P_APP_ID => P_APP_ID,
    P_USER_ID => P_USER_ID,
    P_DATE => P_DATE,
    P_INV_IDS => P_INV_IDS,
    P_AMNTS => P_AMNTS,
    P_PMNT_METHOD => P_PMNT_METHOD,
    P_BANK_AC_FROM => P_BANK_AC_FROM,
    P_CHECK_NUMBERS => P_CHECK_NUMBERS,
    P_MEMO => P_MEMO,
    P_PAY_MULTIPLE => P_PAY_MULTIPLE,
    P_CRD_IDS => P_CRD_IDS,
    P_CRD_AMOUNTS => P_CRD_AMOUNTS,
    O_PY_ID => O_PY_ID
  );
  DBMS_OUTPUT.PUT_LINE('O_PY_ID = ' || O_PY_ID);
END;

我在这一行得到错误

 P_INV_IDS := 32760;

我检查了

的类型
P_INV_IDS WB_PROD.WB_PCK_TYPES.T_IDS;

在Declare语句中,就像这样

type t_ids is table of t_id
   index by binary_integer;

我不知道如何为这种类型提供参数。请告诉我如何提供此参数。

谢谢

2 个答案:

答案 0 :(得分:3)

P_INV_IDS是一个根据你的类型声明的关联数组。

你不能这样分配

P_INV_IDS := 32760;

您需要在P_INV_IDS中指定要为其指定值的索引

类似

P_INV_IDS(0) := 32760;
P_INV_IDS(1) := 32761;

http://www.java2s.com/Tutorial/Oracle/0520__Collections/AssignvaluetoPLSQLtable.htm

答案 1 :(得分:2)

如何定义TYPE t_id?这将决定你如何初始化这个数组。如果是数字,那么您将希望以这种方式初始化您的值:

P_INV_IDS(1) := 32760;

但是,如果将t_id定义为,例如RECORD:

TYPE t_id IS RECORD (
  ID INTEGER;
  DESCRIPTION VARCHAR2(32);
);

然后你可能想要这样初始化:

P_INV_IDS(1).id := 32760;
P_INV_IDS(1).description := 'Description for 32760';