以下就是Oracle多条件查询分页存储过程具体方案的描述,希望在你今后的学习中会有所帮助。将业务逻辑放到Oracle中使得后台代码很精简,Oracle很有搞头!
PL\SQL:
create or replace procedure proc_client_List --客户多条件查询
(
pro_cursor out pkg_order.p_cursor, --查询结果集
characters_ in varchar2,--客户性质
states_ in varchar2,--客户状态
type_ in varchar2,--客户类型
calling_ in varchar2,--客户行业
name_ in varchar2,--客户名称
beginTime_ in date,--创建日期上限
endTime_ in date,--创建日期上限
area_ in number,--客户地区
clientsource_ in varchar2,--客户来源
importent_ in varchar2,--重要程度
start_row in number,--结果集起始行
end_row in number--结果集结束行
1.) is 2.sql_str varchar2(1000):= 3.'select * from 4.( select row_.*, rownum rownum_ from 5.( 6.select * from clientinfo c 7.where(:characters_ is null or c.characters like :characters_) 8.and (:states_ is null or c.states like :states_) 9.and (:type_ is null or c.type like :type_) 10.and (:calling_ is null or c.calling like :calling_) 11.and (:name_ is null or c.name like :name_) 12.and (:beginTime_ is null or c.createtime > :beginTime_) 13.and (:endTime_ is null or c.createtime < :endTime_) 14.and (:area_ is null or c.area=:area_) 15.and (:clientsource_ is null or c.clientsource like :clientsource_) 16.and (:importent_ is null or c.importent like :importent_) 17.) row_ where rownum <= :end_row 18.) 19.where rownum_ > :start_row'; 20.begin 21.open pro_cursor for sql_str using 22.characters_,'%'||characters_||'%', 23.states_,'%'||states_||'%', 24.type_,'%'||type_||'%', 25.calling_,'%'||calling_||'%', 26.name_,'%'||name_||'%', 27.beginTime_,beginTime_, 28.endTime_,endTime_, 29.area_,area_, 30.clientsource_,'%'||clientsource_||'%', 31.importent_,'%'||importent_||'%', 32.end_row,start_row; 33.end proc_client_List;
本文作者:网友 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow