Faster calling of Oracle paging stored procedures

Source: Internet
Author: User
Tags psql

We all know that ASP. NET to call the Oracle paging storage process should be combined with the ASPnetpager paging control to achieve automatic paging function. Before, we used the pagination function provided by the GridView, the speed is really not good. it is decided that the custom paging Oracle database has more than pieces of data, and AspnetPager is doing well.

Oracle paging stored procedure:

Create or replace package JT_P_page is

Type type_cur is ref cursor; defines the cursor variable used to return the record set

Procedure Pagination (Pindex in number, index of the number of pages to be displayed, starting from 0

Psql in varchar2, which generates query statements for paging data

Psize in number, number of records per page

Pcount out number, number of returned pages

Prowcount out number, number of returned records

V_cur out type_cur returns the cursor of the paging data

);

End JT_P_page;

Define the package subject

Create or replace package body JT_P_page is

Procedure Pagination (Pindex in number, index of the number of pages to be displayed, starting from 0

Psql in varchar2, which generates query statements for paging data

Psize in number, number of records per page

Pcount out number, number of returned pages

Prowcount out number, number of returned records

V_cur out type_cur returns the cursor of the paging data

 
 
  1. ) AS  
  2. v_sql VARCHAR2(1000);  
  3. v_Pbegin number;  
  4. v_Pend number;  
  5. begin  
  6. v_sql := 'select count(*) from (' || Psql || ')';  
  7. execute immediate v_sql into Prowcount;  

Calculate the total number of records

 
 
  1. Pcount := ceil(Prowcount / Psize);  

Calculates the total number of pages and displays any page content.

 
 
  1. v_Pend := Pindex * Psize + Psize;  
  2. v_Pbegin := v_Pend - Psize + 1;   
  3. v_sql := 'select * from (' || Psql || ') where rn between ' || v_Pbegin || ' and ' || v_Pend;   
  4. open v_cur for v_sql;  
  5. end Pagination;   
  6. end JT_P_page; 

This is found on the Internet, but it is not bad. It is mainly based on the pseudo column rownum as the where query condition for handsome selection. Through this Oracle paging, we have a preliminary understanding of rownum, in practice, with the Oracle paging Stored Procedure cut down, it is called.

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.