Oracle PL/SQL 根据条件批量收集到一列集合中
我在一个架构中有下表: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
);
这可能吗?
I have the following table in one schema: User_Codes(useri_id, user_code)
. I want to access this table from another schema in a stored proc and minimize the number of round trips between schemas.
In the stored proc I have a collection containing user data along with user ids. I want to fetch corresponding user_codes from other schema using the user_ids. So assuming that rowset
is a collection or SQL TABLE containing user data with filled user_ids and to be filled user_codes, what I want is something like this:
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
);
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一个疯狂的猜测,但这也许对你有用:
Just a wild guess, but maybe this works for you: