gpt4 book ai didi

使用 pls_integer 进行 Oracle 集合

转载 作者:行者123 更新时间:2023-12-02 21:36:17 26 4
gpt4 key购买 nike

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

TYPE type_<xxx> IS TABLE OF <table>.value%TYPE INDEX BY pls_integer;

现在,我使用 .NET 连接到 Oracle,并从参数之一为 type_ type 的包中调用一些方法。一切正常

但是我在包上有另一种方法,包含以下脚本

distinctNewValues := pperiods MULTISET except curweekdayarray;

哪里distinctNewValues , pperiodscurweekdayarraytype_<xxx>类型

编译包时出现错误

distinctNewValues := pperiods MULTISET except curweekdayarray;

错误详细信息:

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;

我可以定义类型而无需 pls_integer指数。但是.NET仅适用于它

最佳答案

您遇到该错误只是因为 multiset 运算符希望将嵌套表视为其操作数,并且您有关联数组。因此,为了能够使用 multiset 运算符,您需要嵌套表。

此匿名 PL/SQL block 将引发 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:

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

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

关于使用 pls_integer 进行 Oracle 集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21315889/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com