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

com.github.chengyuxing.sql.page.impl.OraclePageHelper Maven / Gradle / Ivy

Go to download

Light wrapper of JDBC, support ddl, dml, query, plsql/procedure/function, transaction and manage sql file.

There is a newer version: 9.0.2
Show newest version
package com.github.chengyuxing.sql.page.impl;

import com.github.chengyuxing.sql.Args;
import com.github.chengyuxing.sql.page.PageHelper;

/**
 * 

Oracle page helper, e.g.

*
*
SELECT *
 * FROM (SELECT t.*, ROWNUM RN_4_RABBIT
 *       FROM (...) t
 *       WHERE ROWNUM <= :{@link #END_NUM_KEY})
 *  WHERE RN_4_RABBIT >= :{@link  #START_NUM_KEY}
*
* * @see #pagedArgs() */ public class OraclePageHelper extends PageHelper { public int end() { int end = pageNumber * pageSize; if (end > recordCount) end = recordCount; return end; } public int start() { return (pageNumber - 1) * pageSize + 1; } @Override public String pagedSql(String sql) { return "SELECT *\n" + "FROM (SELECT t.*, ROWNUM " + ROW_NUM_KEY + "\n" + " FROM (" + sql + ") t\n" + " WHERE ROWNUM <= " + end() + ")\n" + " WHERE " + ROW_NUM_KEY + " >= " + start(); } @Override public Args pagedArgs() { return Args.of(START_NUM_KEY, start()).add(END_NUM_KEY, end()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy