this isn't really the way we work - why cannot you just have a query query the actual data?
We can do this, but it isn't "natural" or "normal"
ops$tkyte%ORA11GR2> create type myScalarType as object (
2 user_id number,
3 username varchar2(30),
4 created date )
5 /
Type created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> create type myTableType as table of myScalarType
2 /
Type created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> declare
2 l_data myTabletype;
3 l_data2 myTabletype;
4 begin
5 select myScalarType( user_id, username, created )
6 bulk collect into l_data
7 from all_users
8 where user_id > 1;
9
10 dbms_output.put_line( 'there was ' || l_data.count || ' selected initially ');
11
12 select myScalarType( x.user_id, username, created )
13 bulk collect into l_data2
14 from TABLE( l_data ) x
15 where x.username like '%S%';
16
17 dbms_output.put_line( 'there was ' || l_data2.count || ' selected second time ');
18
19 select myScalarType( x.user_id, username, created )
20 bulk collect into l_data
21 from TABLE( l_data2 ) x
22 where to_char(x.created) like '%DEC%';
23
24 dbms_output.put_line( 'there was ' || l_data.count || ' selected third time ');
25 end;
26 /
there was 40 selected initially
there was 25 selected second time
there was 1 selected third time
PL/SQL procedure successfully completed.
ops$tkyte%ORA11GR2> select count( case when user_id > 1 then 1 end ) cnt1,
2 count( case when user_id > 1 and username like '%S%' then 1 end ) cnt2,
3 count( case when user_id > 1 and username like '%S%' and to_char(created) like '%DEC%' then 1 end ) cnt3
4 from all_users
5 /
CNT1 CNT2 CNT3
---------- ---------- ----------
40 25 1