Java Code Examples for com.alibaba.druid.sql.ast.expr.SQLBinaryOperator#LessThanOrEqual

The following examples show how to use com.alibaba.druid.sql.ast.expr.SQLBinaryOperator#LessThanOrEqual . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DruidSelectOracleParser.java    From Mycat2 with GNU General Public License v3.0 5 votes vote down vote up
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;
                   }

               }

           }

       }
}
 
Example 2
Source File: ShardRange.java    From Zebra with Apache License 2.0 5 votes vote down vote up
private static int convertOperator(SQLBinaryOperator operator) {
	if (operator == SQLBinaryOperator.GreaterThan) {
		return ShardRange.OP_Greater;
	} else if (operator == SQLBinaryOperator.GreaterThanOrEqual) {
		return ShardRange.OP_GreaterOrEqual;
	} else if (operator == SQLBinaryOperator.LessThan) {
		return ShardRange.OP_Less;
	} else if (operator == SQLBinaryOperator.LessThanOrEqual) {
		return ShardRange.OP_LessOrEqual;
	} else if (operator == SQLBinaryOperator.Equality) {
		return ShardRange.OP_Equal;
	} else {
		return ShardRange.OP_NONE;
	}
}
 
Example 3
Source File: ItemFuncLe.java    From dble with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SQLExpr toExpression() {
    SQLExpr left = args.get(0).toExpression();
    SQLExpr right = args.get(1).toExpression();
    return new SQLBinaryOpExpr(left, SQLBinaryOperator.LessThanOrEqual, right);
}