• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SQLSubqueryTableSource类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource的典型用法代码示例。如果您正苦于以下问题:Java SQLSubqueryTableSource类的具体用法?Java SQLSubqueryTableSource怎么用?Java SQLSubqueryTableSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SQLSubqueryTableSource类属于com.alibaba.druid.sql.ast.statement包,在下文中一共展示了SQLSubqueryTableSource类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: toPage

点赞 3

import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource; //导入依赖的package包/类
protected BindSql toPage(PageLimit offsetLimit, SQLUnionQuery union,SQLSelect select, String raw) {
		SQLOrderBy order=removeOrder(union);
		if(order==null){
			throw new UnsupportedOperationException("Select must have order to page");
		}

		StringBuilder sb = new StringBuilder(raw.length() + 40);
//		sb.append("SELECT TOP ").append(offsetLimit[1]).append(" * FROM (\n");
		sb.append("SELECT TOP ");
		sb.append(offsetLimit.getEnd()).append(" * FROM");
		SQLSubqueryTableSource s = new SQLSubqueryTableSource(select,"__ef_tmp1");
		
		SQLServerOutputVisitor visitor=new SQLServerOutputVisitor(sb);
		visitor.setPrettyFormat(false);
		s.accept(visitor);
		sb.append('\n');
		order.accept(visitor);
//		sb.append(") __ef_tmp2\n");
//		appendOrderReverse(order,visitor,"__ef_tmp2",null);
		return new BindSql(sb.toString()).setReverseResult(new ResultSetLaterProcess(offsetLimit.getOffset()));
	}
 

开发者ID:GeeQuery,
项目名称:ef-orm,
代码行数:22,
代码来源:SQL2000LimitHandler.java

示例2: parseThreeLevelPageSql

点赞 2

import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource; //导入依赖的package包/类
private void parseThreeLevelPageSql(SQLStatement stmt, RouteResultset rrs, SchemaConfig schema, SQLSubqueryTableSource from, SQLBinaryOpExpr one, SQLBinaryOperator operator)
{
       SQLIntegerExpr right = (SQLIntegerExpr) one.getRight();
	int firstrownum = right.getNumber().intValue();
	if (operator == SQLBinaryOperator.GreaterThanOrEqual&&firstrownum!=0) {
		firstrownum = firstrownum - 1;
	}
	SQLSelectQuery subSelect = from.getSelect().getQuery();
	if (subSelect instanceof OracleSelectQueryBlock)
       {  //第二层子查询
           OracleSelectQueryBlock twoSubSelect = (OracleSelectQueryBlock) subSelect;
           if (twoSubSelect.getWhere() instanceof SQLBinaryOpExpr && twoSubSelect.getFrom() instanceof SQLSubqueryTableSource)
           {
               SQLBinaryOpExpr twoWhere = (SQLBinaryOpExpr) twoSubSelect.getWhere();
               boolean isRowNum = "rownum".equalsIgnoreCase(twoWhere.getLeft().toString());
               boolean isLess = twoWhere.getOperator() == SQLBinaryOperator.LessThanOrEqual || twoWhere.getOperator() == SQLBinaryOperator.LessThan;
               if (isRowNum && twoWhere.getRight() instanceof SQLIntegerExpr && isLess)
               {
                   int lastrownum = ((SQLIntegerExpr) twoWhere.getRight()).getNumber().intValue();
                   if (operator == SQLBinaryOperator.LessThan&&lastrownum!=0) {
					lastrownum = lastrownum - 1;
				}
                   SQLSelectQuery finalQuery = ((SQLSubqueryTableSource) twoSubSelect.getFrom()).getSelect().getQuery();
                   if (finalQuery instanceof OracleSelectQueryBlock)
                   {
					setLimitIFChange(stmt, rrs, schema, one, firstrownum, lastrownum);
                       parseOrderAggGroupOracle(stmt,rrs, (OracleSelectQueryBlock) finalQuery, schema);
                       isNeedParseOrderAgg=false;
                   }

               }

           }

       }
}
 

开发者ID:huang-up,
项目名称:mycat-src-1.6.1-RELEASE,
代码行数:37,
代码来源:DruidSelectOracleParser.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)