multiset union distinct 给出 "wrong number of types or arguments passed" 错误
multiset union distinct gives "wrong number of types or arguments passed" error
我正在使用 for 循环将不同的值传递给游标,批量收集数据并使用 MULTISET UNION 运算符将其附加到相同的嵌套 table。但是,为了避免重复数据,我尝试使用 MULTISET UNION DISTINCT,但它会抛出错误 PLS-00306: wrong number or types of arguments in call to 'MULTISET_UNION_DISTINCT'
The codes works well without DISTINCT.如果我在这里遗漏任何东西,请告诉我。
我正在使用 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
我的代码如下:
DECLARE
TYPE t_search_rec
IS
RECORD
(
search_id VARCHAR2(200),
search_name VARCHAR2(240),
description VARCHAR2(240) );
TYPE t_search_data
IS
TABLE OF t_search_rec;
in_user_id NUMBER;
in_user_role VARCHAR2(20);
in_period VARCHAR2(20) := 'Sep-15';
in_search_string VARCHAR2(20) := 'v';
l_search_tt t_search_data;
x_search_tt t_search_data;
v_entity_gl VA_LOGIN_API.t_entity_list ;
X_RETURN_CODE VARCHAR2(20);
X_RETURN_MSG VARCHAR2(2000);
CURSOR c_vendors_gl(v_entity VARCHAR2)
IS
SELECT UNIQUE vendor_id,
vendor,
NULL description
FROM XXPOADASH.XX_VA_PO_LINES
WHERE period = in_period
AND entity = v_entity
AND upper(vendor) LIKE upper(in_search_string)
||'%';
BEGIN
in_user_role := 'ROLE';
in_user_id := 4359;
VA_LOGIN_API.DATA_ACCESS_PROC( X_RETURN_CODE => X_RETURN_CODE, X_RETURN_MSG => X_RETURN_MSG, IN_PERSON_ID => in_user_id, IN_PERSON_ROLE => in_user_role, X_ACCESSED_ENTITY_LIST => v_entity_gl );
IF( v_entity_gl.COUNT >0) THEN
x_search_tt := t_search_data();
FOR I IN v_entity_gl.FIRST..v_entity_gl.COUNT
LOOP
OPEN c_vendors_gl(v_entity_gl(i));
FETCH c_vendors_gl BULK COLLECT INTO l_search_tt;
CLOSE c_vendors_gl;
x_search_tt := x_search_tt MULTISET
UNION DISTINCT l_search_tt;
l_search_tt.delete;
END LOOP;
IF x_search_tt.count = 0 THEN
x_return_msg := 'No lines found';
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE(x_return_msg);
DBMS_OUTPUT.PUT_LINE(x_search_tt.count);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(x_return_msg);
DBMS_OUTPUT.PUT_LINE(x_search_tt.count);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
multiset union distinct
要求集合的元素具有可比性。在您的情况下,元素是 PL/SQL 记录,不幸的是它们不是可比较的数据结构(即 PL/SQL 没有提供内置机制来比较 PL/SQL 记录)。
multiset union
有效,因为它不需要比较元素。
一种可能的解决方法是使用 Oracle 对象类型而不是 PL/SQL 记录。对象类型允许您 implement a comparison method 所需 multiset union distinct
.
我正在使用 for 循环将不同的值传递给游标,批量收集数据并使用 MULTISET UNION 运算符将其附加到相同的嵌套 table。但是,为了避免重复数据,我尝试使用 MULTISET UNION DISTINCT,但它会抛出错误 PLS-00306: wrong number or types of arguments in call to 'MULTISET_UNION_DISTINCT'
The codes works well without DISTINCT.如果我在这里遗漏任何东西,请告诉我。
我正在使用 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
我的代码如下:
DECLARE
TYPE t_search_rec
IS
RECORD
(
search_id VARCHAR2(200),
search_name VARCHAR2(240),
description VARCHAR2(240) );
TYPE t_search_data
IS
TABLE OF t_search_rec;
in_user_id NUMBER;
in_user_role VARCHAR2(20);
in_period VARCHAR2(20) := 'Sep-15';
in_search_string VARCHAR2(20) := 'v';
l_search_tt t_search_data;
x_search_tt t_search_data;
v_entity_gl VA_LOGIN_API.t_entity_list ;
X_RETURN_CODE VARCHAR2(20);
X_RETURN_MSG VARCHAR2(2000);
CURSOR c_vendors_gl(v_entity VARCHAR2)
IS
SELECT UNIQUE vendor_id,
vendor,
NULL description
FROM XXPOADASH.XX_VA_PO_LINES
WHERE period = in_period
AND entity = v_entity
AND upper(vendor) LIKE upper(in_search_string)
||'%';
BEGIN
in_user_role := 'ROLE';
in_user_id := 4359;
VA_LOGIN_API.DATA_ACCESS_PROC( X_RETURN_CODE => X_RETURN_CODE, X_RETURN_MSG => X_RETURN_MSG, IN_PERSON_ID => in_user_id, IN_PERSON_ROLE => in_user_role, X_ACCESSED_ENTITY_LIST => v_entity_gl );
IF( v_entity_gl.COUNT >0) THEN
x_search_tt := t_search_data();
FOR I IN v_entity_gl.FIRST..v_entity_gl.COUNT
LOOP
OPEN c_vendors_gl(v_entity_gl(i));
FETCH c_vendors_gl BULK COLLECT INTO l_search_tt;
CLOSE c_vendors_gl;
x_search_tt := x_search_tt MULTISET
UNION DISTINCT l_search_tt;
l_search_tt.delete;
END LOOP;
IF x_search_tt.count = 0 THEN
x_return_msg := 'No lines found';
END IF;
END IF;
DBMS_OUTPUT.PUT_LINE(x_return_msg);
DBMS_OUTPUT.PUT_LINE(x_search_tt.count);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(x_return_msg);
DBMS_OUTPUT.PUT_LINE(x_search_tt.count);
DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;
multiset union distinct
要求集合的元素具有可比性。在您的情况下,元素是 PL/SQL 记录,不幸的是它们不是可比较的数据结构(即 PL/SQL 没有提供内置机制来比较 PL/SQL 记录)。
multiset union
有效,因为它不需要比较元素。
一种可能的解决方法是使用 Oracle 对象类型而不是 PL/SQL 记录。对象类型允许您 implement a comparison method 所需 multiset union distinct
.