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;
import org.jetbrains.annotations.NotNull;

/**
 * 

Oracle page helper, e.g.

*
*
select *
 * from (select t.*, rownum {@link #ROW_NUM_KEY}
 *       from (...) t
 *       where rownum <= :{@link #END_NUM_KEY})
 *  where {@link #ROW_NUM_KEY} >= :{@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 @NotNull String pagedSql(char namedParamPrefix, @NotNull String sql) { return "select *\n" + "from (select t.*, rownum " + ROW_NUM_KEY + "\n" + " from (" + sql + ") t\n" + " where rownum <= " + namedParamPrefix + END_NUM_KEY + ")\n" + " where " + ROW_NUM_KEY + " >= " + namedParamPrefix + START_NUM_KEY; } @Override public @NotNull Args pagedArgs() { return Args.of(START_NUM_KEY, start()).add(END_NUM_KEY, end()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy