Oracle multi-condition Query

Source: Internet
Author: User

The following articles mainly introduce the paging Stored Procedure of Oracle multi-condition query. The following describes the specific solution of the paging Stored Procedure of Oracle multi-condition query. I hope this will help you in your future studies. Putting the business logic in Oracle makes the background code very concise, and Oracle is very creative!

PL \ SQL:

Create or replace procedure proc_client_List -- customer multi-condition Query

(

Pro_cursor out pkg_order.p_cursor, -- query result set

Characters _ in varchar2, -- customer nature

States _ in varchar2, -- customer status

Type _ in varchar2, -- customer type

Calling _ in varchar2, -- customer Industry

Name _ in varchar2, -- CUSTOMER name

BeginTime _ in date, -- upper limit of creation date

EndTime _ in date, -- maximum creation date

Area _ in number, -- customer Region

Clientsource _ in varchar2, -- customer Source

Importent _ in varchar2, -- Importance

Start_row in number, -- start row of the result set

End_row in number -- end row of the result set

 
 
  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;   

The above content is the description of the paging Stored Procedure for Oracle multi-condition query. I hope it will help you in this regard.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.