|
发表于 2013-12-22 17:08:12
|
显示全部楼层
分享一下Oracle sql分页
public static Table eQueryPM_PointsForMain1(String concept, String select,
String from, String aggregate, String dataModel, String fnModel,
String condition, List range, Boolean distinct, String idColumn,
String filter, Integer limit, Integer offset, String columns,
String orderBy, String aggregateColumns, Map variables) {
String sql = "copy代码换成自己的sql就行";
if (filter != null) {
sql += " where 1=1 and " + filter;
}
String offSql = "select * from (select rownum rn,A.* from (" + sql+ ") A where rownum <= " + (offset + limit) + ") where rn >="
+ (offset + 1) + "";
Map<String, String> map = new HashMap<String, String>();
map.clear();
map.put("ORACLE", offSql);
t = SQL.select(map, null, "/PMS/subcontractorsmanager/negotiatingChanges/data");
// 设置table的rowid属性
t.getProperties().put(Table.PROP_NAME_ROWID, "FID");
// 设置table的count属性,总记录数,用于分页
String countNum = "select count(*) as FNUM from ( " + sql + " )";
Map<String, String> map1 = new HashMap<String, String>();
map1.clear();
map1.put("ORACLE", countNum);
Table countTable = SQL.select(map1, null, "/PMS/subcontractorsmanager/negotiatingChanges/data");
BigDecimal num = countTable.iterator().next().getDecimal("FNUM");
t.getProperties().put(Table.PROP_DB_COUNT, num);
return t;
} |
|