数値のリストをplsql変数にクエリし、それを別のSQLクエリのin句で使用したいと思います。やりたいことのテストケースを以下に作成しました。
私は解決策のためにグーグルをしました、そしてそれはどういうわけか可能であるに違いないと思います、しかし私はそれを実行させません。コンパイルソリューションを手伝ってください。
CREATE OR REPLACE PROCEDURE PROCEDURE1
as
type t_id is table of number;
v_ids t_id;
v_user_ids number;
BEGIN
-- fill variable v_id with id's, user_id is of type number
select user_id
bulk collect into v_ids
from user_users;
-- then at a later stage ... issue a query using v_id in the in clause
select user_id into v_user_ids from user_users
-- this line does not compile ( local collection type not allowed in SQL statements)
where user_id in ( v_ids );
END PROCEDURE1;