使用pls_integer进行oracle集合

AEM*_*iji 1 oracle plsql

我在oracle中创建了包,并定义了类型如下

TYPE type_<xxx> IS TABLE OF <table>.value%TYPE INDEX BY pls_integer;
Run Code Online (Sandbox Code Playgroud)

现在我将.NET连接到oracle并从包中调用一些方法,其中一个参数是type_type.一切正常

但我在包下面的脚本上有另一种方法

distinctNewValues := pperiods MULTISET except curweekdayarray;
Run Code Online (Sandbox Code Playgroud)

在那里distinctNewValues,pperiods 并且curweekdayarraytype_<xxx> 类型

编译包时会出错

distinctNewValues := pperiods MULTISET except curweekdayarray;
Run Code Online (Sandbox Code Playgroud)

错误详情:

line.

error:Compilation errors for PACKAGE BODY <schema>.<pkg_name>

Error: PLS-00306: wrong number or types of arguments in call to 'MULTISET_EXCEPT_ALL'
Line: 163
Text: distinctNewValues := pperiods MULTISET except  curweekdayarray;

Error: PL/SQL: Statement ignored
Line: 163
Text: distinctNewValues := pperiods MULTISET except  curweekdayarray;
Run Code Online (Sandbox Code Playgroud)

我可以定义没有pls_integer索引的类型.但.NET只能用它

Nic*_*nov 5

您正面临该错误,因为multiset运算符期望将嵌套表视为其操作数,并且您具有关联数组.因此,为了能够使用multiset运算符,您需要嵌套表.

这个匿名的PL/SQL块会引发PLS-00306错误:

declare
  type t_list is table of number index by pls_integer; -- associative array
  l_col1 t_list;
  l_col2 t_list;
  l_col_res t_list;
begin
  l_col1(1) := 1;
  l_col2(1) := 1;
  l_col_res := l_col1 multiset except l_col2;
end;

PLS-00306: wrong number or types of arguments in call to 'MULTISET_EXCEPT_ALL'
ORA-06550: line 9, column 3:
Run Code Online (Sandbox Code Playgroud)

而这个不会(将我们的关联数组更改为嵌套表):

declare
  type t_list is table of number; -- nested table
  l_col1 t_list := t_list(1,2,3);
  l_col2 t_list := t_list(1,2);
  l_col_res t_list;
begin
  l_col_res := l_col1 multiset except l_col2;
end;


anonymous block completed
Run Code Online (Sandbox Code Playgroud)