问题描述
我被这个错误困住了,真的不知道如何解决它.也许我以不正确的方式传递了数组?
I'm stuck with this error and really don't know how to fix it. Maybe i'm passing array in improper way?
这是主要的sql文件.
This is main sql file.
DECLARE
v_array_length NUMBER := &v_array_length;
BEGIN
DECLARE
TYPE number_array_type IS TABLE OF NUMBER(6, 2) INDEX BY BINARY_INTEGER;
v_array NUMBER_ARRAY_TYPE;
BEGIN
--Isvediams
IOPACKAGE.OUTPUT_MESSAGE('Original array:');
--Sugeneruoja atsitiktinius array elementus is intervalo [1, 1000]
FOR i IN 1..v_array_length LOOP
v_array(i) := SYS.DBMS_RANDOM.VALUE(1, 1000);
END LOOP;
IOPACKAGE.OUTPUT_ARRAY(v_array);
END;
END;
这是IOpackage sql文件
This is IOpackage sql file
CREATE OR REPLACE PACKAGE IOpackage IS
l_message VARCHAR2(100);
PROCEDURE output_message(l_message IN VARCHAR2);
TYPE number_array_type IS TABLE OF NUMBER(6, 2) INDEX BY BINARY_INTEGER;
PROCEDURE output_array(v_array NUMBER_ARRAY_TYPE);
END IOpackage;
这是IOpackage_body文件.
and this is IOpackage_body file.
CREATE OR REPLACE PACKAGE BODY IOpackage IS
PROCEDURE output_message(l_message IN VARCHAR2) IS
BEGIN
DBMS_OUTPUT.PUT_LINE(l_message);
END output_message;
PROCEDURE output_array(v_array IN NUMBER_ARRAY_TYPE) IS
BEGIN
FOR i IN 1..v_array.COUNT LOOP
DBMS_OUTPUT.PUT(v_array(i) || ' ');
END LOOP;
DBMS_OUTPUT.PUT_LINE('');
END output_array;
END IOpackage;
推荐答案
主sql文件中的类型定义不是程序包子例程所需的类型. IOPACKAGE.OUTPUT_ARRAY
-子例程期望类型为IOPACKAGE.NUMBER_ARRAY_TYPE
.您不必重新定义类型.以下应该可以工作:
The type definition in main sql file is not the type that is expected by the package subroutine. IOPACKAGE.OUTPUT_ARRAY
-subroutine expects type IOPACKAGE.NUMBER_ARRAY_TYPE
. You don't have to re-define the type. The following should work:
declare
v_array IOPACKAGE.NUMBER_ARRAY_TYPE;
begin
IOPACKAGE.OUTPUT_ARRAY(v_array);
end;
查看IOPACKAGE.NUMBER_ARRAY_TYPE
和NUMBER_ARRAY_TYPE
之间的区别.它们相似但不相同.
See the difference between IOPACKAGE.NUMBER_ARRAY_TYPE
and NUMBER_ARRAY_TYPE
. They are similar but not the same.
这篇关于PLS-00306:调用"OUTPUT_ARRAY"时参数的数量或类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!