zoukankan      html  css  js  c++  java
  • sql 绑定变量问题

    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,这里不需要使用绑定变量。
    

  • 相关阅读:
    Systemd 入门教程:实战篇
    Systemd 入门教程:命令篇
    awk详解
    yum Multilib version problems
    Oracle ORA 12541 报错解决过程
    创建表空间
    大文件按行分离脚本
    heartbeat安装与配置
    Keepalived安装配置
    速查表的名称和建表语句
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349525.html
Copyright © 2011-2022 走看看