以下程序使用调用invoicetest.wj_get_invoicedatatest(1,:InvoicesCur)给出错误;调用invoicetest.wj_get_invoice_cbodataidstest('X');

时间:2016-10-03 09:02:14

标签: oracle

我在使用boyh程序调用后出错了

CREATE OR REPLACE PACKAGE invoicetest 
    IS
        TYPE InvoiceCBOIDCurs IS REF CURSOR;
        TYPE InvoicesCur IS REF CURSOR;

         PROCEDURE wj_get_invoice_cbodataidstest
    (
         InvoiceCBOIDs out InvoiceCBOIDCurs
    );
         PROCEDURE wj_get_invoicedatatest
    (
         Invoice out InvoicesCur,
         CBOID IN INTEGER
    );
    END invoicetest;
    /

    CREATE OR REPLACE PACKAGE BODY invoicetest IS
    PROCEDURE wj_get_invoice_cbodataidstest
    (
         InvoiceCBOIDs out InvoiceCBOIDCurs
    )
    IS
    BEGIN
         OPEN InvoiceCBOIDs FOR
                 Select 1 from dual;
    END wj_get_invoice_cbodataidstest;

    PROCEDURE wj_get_invoicedatatest
    (
         Invoice out InvoicesCur,
         CBOID IN INTEGER
    )as
    begin
     OPEN Invoice FOR
     select cboid from dual;
    end wj_get_invoicedatatest;
    END invoicetest;
    /
电话后

错误:

  

invoicetest.wj_get_invoicedatatest(1,:InvoicesCur);呼叫   invoicetest.wj_get_invoice_cbodataidstest( 'X');

1 个答案:

答案 0 :(得分:0)

你的程序还可以,但你是以错误的方式打电话给他们;在一种情况下,您使用错误顺序的参数,而在另一种情况下,您正在传递varchar,而过程需要一个游标参数。 这是调用程序的正确方法:

SQL> declare
  2      vCurCBO invoicetest.InvoiceCBOIDCurs;
  3      vCur    invoicetest.InvoicesCur;
  4  begin
  5      invoicetest.wj_get_invoicedatatest(vCur, 1);
  6      --
  7      invoicetest.wj_get_invoice_cbodataidstest(vCurCBO);
  8      --
  9      /* what you need to do with your cursors */
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL>

为避免混淆,您可以通过明确使用其名称来传递参数:

...
invoicetest.wj_get_invoicedatatest(
                                   Invoice       =>vCur,
                                   CBOID         => 1
                                  );
--
invoicetest.wj_get_invoice_cbodataidstest(
                                            InvoiceCBOIDs => vCurCBO
                                         );
...

如果您需要使用CALL:

SQL> VARIABLE vCurCBO REFCURSOR;
SQL> VARIABLE vCur REFCURSOR;
SQL> CALL invoicetest.wj_get_invoice_cbodataidstest(
  2                                                  InvoiceCBOIDs => :vCurCBO
  3                                               );

Call completed.

SQL> CALL invoicetest.wj_get_invoicedatatest(
  2                                         Invoice       =>:vCur,
  3                                         CBOID         => 1
  4                                        );

Call completed.

SQL>