oracle PL/SQL:为数字表触发错误“PLS-00306:调用中的参数数量或类型错误”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19543343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 05:20:12  来源:igfitidea点击:

PL/SQL: Error "PLS-00306: wrong number or types of arguments in call to" triggered for table of numbers

oracleplsql

提问by Alin

I'm trying to call an API using the exact procedure signature, but somehow the table of numbers I don't think is recognize correctly.

我正在尝试使用确切的过程签名调用 API,但不知何故,我认为数字表无法正确识别。

API definition:

API定义:

TYPE NUMLIST IS TABLE OF NUMBER INDEX BY VARCHAR2(50);

PROCEDURE GETSERVICES_API
(
   I_DIMOBJID IN NUMBER, I_OBJECTID IN NUMBER, I_FILTER IN NUMBER, 
   O_ERRORCODE OUT NUMBER, O_ERRORTEXT OUT VARCHAR2, O_SERVICELIST OUT NUMLIST
);

My call of API:

我对 API 的调用:

DECLARE

   TYPE NUMLIST IS TABLE OF NUMBER INDEX BY VARCHAR2(50);
   lt_SERVICELIST              NUMLIST;

   ls_errortext             varchar2(100);
   ln_errorcode             number;

BEGIN


    PKGCOMSUPPORT_SERVICE.GETSERVICES_API(I_DIMOBJID => 6,
                                          I_OBJECTID => 5263,
                                          I_FILTER => 3,
                                          O_ERRORCODE => ln_errorcode,
                                          O_ERRORTEXT => ls_errortext,
                                          O_SERVICELIST => lt_SERVICELIST);

END;

When I run my call of API I got: PLS-00306: wrong number of types of arguments in call to 'GETSERVICE_API

当我运行 API 调用时,我得到:PLS-00306:调用 'GETSERVICE_API 时参数类型的数量错误

Any idea why? Thanks

知道为什么吗?谢谢

采纳答案by Nick Krasnov

The reason why you are facing the PLS-00306error is incompatibility of NUMLISTcollection type, defined in the package specification and NUMLISTcollection type defined in the anonymous PL/SQL block. Even though definitions of those two collection types are the same, they are not compatible. In your anonymous PL/SQL block you have to declare and then pass into the GETSERVICES_APIprocedure a variable of PKGCOMSUPPORT_SERVICE.NUMLISTdata type.

您遇到PLS-00306错误的原因是NUMLIST在包规范中NUMLIST定义的集合类型与匿名 PL/SQL 块中定义的集合类型不兼容。尽管这两种集合类型的定义相同,但它们并不兼容。在您的匿名 PL/SQL 块中,您必须声明GETSERVICES_API一个PKGCOMSUPPORT_SERVICE.NUMLIST数据类型的变量,然后将其传递给过程 。

create or replace package PKG as
  type t_numlist is table of number index by varchar2(50);
  procedure SomeProc(p_var in pkg.t_numlist);
end;
/

create or replace package body PKG as
  procedure someproc(p_var in pkg.t_numlist) is
  begin
    null;
  end;
end;
/

declare
  type t_numlist is table of number index by varchar2(50);
  l_var t_numlist;
begin
  pkg.someproc(l_var);
end;

ORA-06550: line 5, column 3:
PLS-00306: wrong number or types of arguments in call to 'SOMEPROC'

declare
  --type t_numlist is table of number index by varchar2(50);
  l_var pkg.t_numlist;
begin
  pkg.someproc(l_var);
end;

anonymous block completed

回答by Filip

I had also the PLS-00306 error, but the cause was different. In my case, I was using wrong name of argument. I've got procedure: FUNCTION get_card_list(p_clob_in IN CLOB, o_clob_out OUT CLOB)

我也有 PLS-00306 错误,但原因不同。就我而言,我使用了错误的参数名称。我有程序:FUNCTION get_card_list(p_clob_in IN CLOB, o_clob_out OUT CLOB)

The arguments names are p_clob_inand o_clob_out, so I should call this procedure by: get_card_list(p_clob_in=>inner, o_clob_out=>outer)or get_card_list(inner, outer), but I was using wrong argument names: p_xml& o_xml: get_card_list(p_xml=>inner, o_xml=>outer)

参数名称是p_clob_ino_clob_out,所以我应该通过:get_card_list(p_clob_in=>inner, o_clob_out=>outer)or调用这个过程get_card_list(inner, outer),但我使用了错误的参数名称:p_xml& o_xmlget_card_list(p_xml=>inner, o_xml=>outer)

This YT video helps me a lot: https://www.youtube.com/watch?v=xwMVL3Z_vn8

这个 YT 视频对我有很大帮助:https: //www.youtube.com/watch?v=xwMVL3Z_vn8

回答by Andrew Cruickshank

I think the type definition is invalid. To create a table 'type' you need something like the following:

我认为类型定义无效。要创建表“类型”,您需要如下内容:

CREATE OR REPLACE TYPE NUMLIST AS OBJECT (COLUMN1 VARCHAR2(50));

回答by mucio

maybe you can try this:

也许你可以试试这个:

CREATE TYPE NUMLIST AS TABLE OF NUMBER INDEX BY VARCHAR2(50);

DECLARE

   lt_SERVICELIST              NUMLIST;

   ls_errortext             varchar2(100);
   ln_errorcode             number;

BEGIN


    PKGCOMSUPPORT_SERVICE.GETSERVICES_API(I_DIMOBJID => 6,
                                          I_OBJECTID => 5263,
                                          I_FILTER => 3,
                                          O_ERRORCODE => ln_errorcode,
                                          O_ERRORTEXT => ls_errortext,
                                          O_SERVICELIST => lt_SERVICELIST);

END;