SQL> create table T_BUSINESS_DATA(user_id number(16),status varchar2(2),oper_date date);
select * from T_BUSINESS_DATA t where 1=1 and t.APP_USER_ID=:userId and t.STATUS <> 1 order by t.operDate desc
SQL> variable userId number;
SQL> exec :userId := 1;
PL/SQL procedure successfully completed.
select *
from T_BUSINESS_DATA t
where 1 = 1
and t.user_id = :userId
and t.STATUS <> 1
order by t.oper_date desc
SQL> select distinct user_id from T_BUSINESS_DATA;
USER_ID
----------
1
2222
999
3
10
select *
from T_BUSINESS_DATA t
where 1 = 1
and t.user_id = :userId
and t.STATUS <> 2
order by t.oper_date desc;
select *
from T_BUSINESS_DATA t
where 1 = 1
and t.user_id = :userId
and t.STATUS <> 3
order by t.oper_date desc;
select *
from T_BUSINESS_DATA t
where 1 = 1
and t.user_id = :userId
and t.STATUS <> 4
order by t.oper_date desc;
select *
from T_BUSINESS_DATA t
where 1 = 1
and t.user_id = :userId
and t.STATUS <> 5
order by t.oper_date desc;
SQL_TEXT SQL_ID EXECUTIONS
1 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 4 order by t.oper_date desc 2kykjpbwrbmxr 1
2 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 3 order by t.oper_date desc 8wqactbjt4vr5 1
3 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 5 order by t.oper_date desc 9x1nbtnky71hd 2
4 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 1 order by t.oper_date desc 03cr9uphjkkct 1
5 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 2 order by t.oper_date desc 86y3ddg9wzhg1 1
6 select * from T_BUSINESS_DATA t where 1 = 1 and t.user_id = :userId and t.STATUS <> 4 order by t.oper_date desc a2f1chc53b5nq 1
7 select sql_text, sql_id, a.executions from v$sql a where a.parsing_schema_name = 'TEST' and sql_text like '%oper_date%' order by 1,last_active_time desc 1dwfvvkxmqn95 5
有5种状态,就会在内存里存在5条sql cursor,这里不需要使用绑定变量。