Oracle 如何从一个dbms_sql.number_表选择到另一个dbms_sql.number_表
我将索引列表(包括重复项)作为dbms_sql.number_表传递到一个函数中,并希望从中选择唯一的条目到另一个dbms_sql.number_表中 到目前为止,我已经大致了解了以下内容:Oracle 如何从一个dbms_sql.number_表选择到另一个dbms_sql.number_表,oracle,plsql,Oracle,Plsql,我将索引列表(包括重复项)作为dbms_sql.number_表传递到一个函数中,并希望从中选择唯一的条目到另一个dbms_sql.number_表中 到目前为止,我已经大致了解了以下内容: function selectIndices(tlngIndexList in in dbms_sql.number_table) return number is tlngUniqueIndices dbms_sql.number_table; begin select distinct * fr
function selectIndices(tlngIndexList in in dbms_sql.number_table) return number
is
tlngUniqueIndices dbms_sql.number_table;
begin
select distinct * from tlngIndexList into tlngUniqueIndices;
--Etc
虽然SQLDeveloper给了我一个“ORA-00942:表或视图不存在”错误,所以这似乎不是正确的方法。有什么想法吗?提前感谢。从SQL查询填充集合的语法为:
select x bulk collect into y from z;
12.2中的以下内容(可能是12.1,但未经测试):
在早期版本中,您可以尝试使用集合的值作为第二个集合的索引,作为消除重复数据的一种方法:
create or replace function selectIndices
( tlngIndexList in dbms_sql.number_table )
return number
as
tlngUniqueIndices dbms_sql.number_table;
i pls_integer := tlngIndexList.first;
begin
while i is not null loop
tlngUniqueIndices(tlngIndexList(i)) := tlngIndexList(i);
i := tlngIndexList.next(i);
end loop;
return tlngUniqueIndices.count;
end selectIndices;
number\u表
是一个关联表(按二进制整数索引)。假设您正在寻找重复的值,但是如果您找到了任何值,那么您希望结果具有什么索引?它们必须是关联数组还是可以使用嵌套表?我使用的是11.2,但后一种方法似乎有效。谢谢
create or replace function selectIndices
( tlngIndexList in dbms_sql.number_table )
return number
as
tlngUniqueIndices dbms_sql.number_table;
i pls_integer := tlngIndexList.first;
begin
while i is not null loop
tlngUniqueIndices(tlngIndexList(i)) := tlngIndexList(i);
i := tlngIndexList.next(i);
end loop;
return tlngUniqueIndices.count;
end selectIndices;