1

我在一个模式中有下表:User_Codes(useri_id, user_code). 我想从存储过程中的另一个模式访问这个表,并尽量减少模式之间的往返次数。

在存储过程中,我有一个包含用户数据和用户 ID 的集合。我想使用 user_ids 从其他模式中获取相应的 user_codes。因此,假设这rowset是一个集合或 SQL TABLE,其中包含填充了 user_ids 和要填充 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
);

这可能吗?

4

1 回答 1

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;
于 2011-11-28T23:20:22.427 回答