/// <summary>
/// 返回分页SQL语句
/// </summary>
/// <param name="selectSql">查询SQL语句</param>
/// <param name="PageIndex">当前页码</param>
/// <param name="PageSize">一页多少条记录</param>
/// <returns></returns>
public static string getPageSplitSQL(string selectSql, int PageIndex, int PageSize)
{
string StartSelectSql = @" select * from (select aa.*, rownum r from (";
int CurrentReadRows = PageIndex * PageSize;
int startRow = (CurrentReadRows - PageSize) < 0 ? 0 : (CurrentReadRows - PageSize);
int endRow = CurrentReadRows == 0 ? PageSize : CurrentReadRows;
string EndSelectSql = string.Format(") aa where rownum <= {1}) bb where r >{0} ", startRow, endRow);
return StartSelectSql + selectSql + EndSelectSql;
}
Oracle或sql2005分页
最新推荐文章于 2025-12-02 09:49:43 发布
本文介绍了一种生成分页SQL的方法,通过输入查询SQL语句、当前页码及每页记录数来返回特定的分页SQL。该方法适用于Oracle数据库环境,通过ROWNUM进行分页处理。
551

被折叠的 条评论
为什么被折叠?



