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

  • 相关阅读:
    Redis 学习(二十)服务器
    Redis 学习(十八)连接
    Redis学习(十七) 脚本
    Redis学习(十六)事务
    Redis学习(十四) 发布订阅
    python中如何使用requests模块下载文件并获取进度提示?
    Python实例获取mp3文件的tag信息
    python 视频处理,提取视频相关帧,读取Excel
    爬虫数据采集技术趋势-智能化解析
    Python中文转拼音代码(支持全拼和首字母缩写)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349525.html
Copyright © 2011-2022 走看看