2011-11-28 26 views
1

我在一个模式中具有下表:User_Codes(useri_id, user_code)。我想从存储过程中的另一个模式访问此表,并尽量减少模式之间的往返次数。Oracle PL/SQL Bulk根据条件收集到一个集合列中

在存储过程中,我有一个包含用户数据和用户ID的集合。我想使用user_ids从其他架构中获取相应的user_code。所以假设rowset是一家集或包含用户数据与填充user_ids SQL表,并成为充满user_codes,我想是这样的:

select uc.user_code 
bulk collect into rowset.user_code 
from other_schema.user_codes uc 
where uc.user_id in (
select distinct rowset_table.user_id 
from table(rowset) rowset_table 
where rowset_table.user_id is not null 
); 

这可能吗?

回答

0

只是胡乱猜测,但也许这对你的作品:

select rs.user_id, uc.user_code 
    bulk collect into rowset 
    from other_schema.user_codes uc, table(rowset) rs 
    where uc.user_id = rs.user_id; 
相关问题