首页 > 解决方案 > 在 oracle 中使用嵌套表打印元素

问题描述

我正在研究一个具有两个集合类型参数的过程。
样本数据:

accounts

accountid     
2                
3                  
4    

rts_accounts

accountid
2  
3  
5  

输入: 1,2,3,4,5
所需输出: 4,5

我知道我们可以通过普通的 sql 来实现它,但我希望它包含在一个集合中,因为我们的表有数百万条记录。请有人帮助我使用收集方法解决此问题。

到目前为止我的代码:

create or replace PROCEDURE delete_account_stg (  
       in_accounts IN  test_coll,  
       out_accounts       OUT test_coll)  
IS  
 result_coll test_coll;  
 result1_coll test_coll;  
BEGIN  
  SELECT test_type( account_id )  
  BULK COLLECT INTO result_coll  
  FROM table(in_accounts);  

 select  test_type(a.account_id )  
 bulk collect into result1_coll  
 from accounts a inner join rts_accounts b on a.account_id = b.account_id;  

select result_coll MULTISET except  result1_coll into out_accounts from dual;  

END delete_account_stg;  

我得到的输出为:
1,4,5但我想要4,5.

标签: oracleplsqlcollectionsnested-table

解决方案


推荐阅读