All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zhuang.data.pagination.OraclePaging Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
package com.zhuang.data.pagination;

import com.zhuang.data.util.SqlUtils;

public class OraclePaging extends DbPaging {

    @Override
    public String getPageSql(String sql, String orderClause, int startRowIndex, int rowCount) {
        sql = SqlUtils.removeOrderByClause(sql);
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("select * from (select * from (select row_.*, rownum rownum_ from ( ");
        stringBuilder.append(sql);
        if (orderClause != null && !orderClause.isEmpty()) {
            stringBuilder.append(" Order By ").append(orderClause);
        }
        stringBuilder.append("\n ) row_) where rownum_ <= ").append(startRowIndex + rowCount - 1).append(") where rownum_ >= ").append(startRowIndex);
        return stringBuilder.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy