本文整理汇总了Java中com.alibaba.druid.sql.ast.expr.SQLBetweenExpr类的典型用法代码示例。如果您正苦于以下问题:Java SQLBetweenExpr类的具体用法?Java SQLBetweenExpr怎么用?Java SQLBetweenExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLBetweenExpr类属于com.alibaba.druid.sql.ast.expr包,在下文中一共展示了SQLBetweenExpr类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visit
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public boolean visit(SQLBetweenExpr x) {
if(requireParameterizedOutput){
return super.visit(x);
}
ExportParameterVisitorUtils.exportParameter(this.parameters, x);
return true;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:10,代码来源:DB2ExportParameterVisitor.java
示例2: visit
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public boolean visit(SQLBetweenExpr x) {
if(requireParameterizedOutput){
return super.visit(x);
}
ExportParameterVisitorUtils.exportParameter(this.parameters, x);
return true;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:9,代码来源:OracleExportParameterVisitor.java
示例3: visit
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public boolean visit(SQLBetweenExpr x) {
if(requireParameterizedOutput){
return super.visit(x);
}
ExportParameterVisitorUtils.exportParameter(this.parameters, x);
return true;
}
开发者ID:zuonima,项目名称:sql-utils,代码行数:9,代码来源:MySqlExportParameterVisitor.java
示例4: toExpression
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
SQLExpr first = args.get(0).toExpression();
SQLExpr second = args.get(1).toExpression();
SQLExpr third = args.get(2).toExpression();
return new SQLBetweenExpr(first, this.negated, second, third);
}
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ItemFuncBetweenAnd.java
示例5: getOwnerTableName
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
/**
* 从between语句中获取字段所属的表名。
* 对于容易出现ambiguous的(字段不知道到底属于哪个表),实际应用中必须使用别名来避免歧义
* @param betweenExpr
* @param column
* @return
*/
private String getOwnerTableName(SQLBetweenExpr betweenExpr,String column) {
if(tableStats.size() == 1) {//只有一个表,直接返回这一个表名
return tableStats.keySet().iterator().next().getName();
} else if(tableStats.size() == 0) {//一个表都没有,返回空串
return "";
} else {//多个表名
for (Column col : columns.keySet())
{
if(col.getName().equals(column)) {
return col.getTable();
}
}
// for(Column col : columns) {//从columns中找表名
// if(col.getName().equals(column)) {
// return col.getTable();
// }
// }
//前面没找到表名的,自己从parent中解析
SQLObject parent = betweenExpr.getParent();
if(parent instanceof SQLBinaryOpExpr)
{
parent=parent.getParent();
}
if(parent instanceof MySqlSelectQueryBlock) {
MySqlSelectQueryBlock select = (MySqlSelectQueryBlock) parent;
if(select.getFrom() instanceof SQLJoinTableSource) {//多表连接
SQLJoinTableSource joinTableSource = (SQLJoinTableSource)select.getFrom();
return joinTableSource.getLeft().toString();//将left作为主表,此处有不严谨处,但也是实在没有办法,如果要准确,字段前带表名或者表的别名即可
} else if(select.getFrom() instanceof SQLExprTableSource) {//单表
return select.getFrom().toString();
}
}
else if(parent instanceof SQLUpdateStatement) {
SQLUpdateStatement update = (SQLUpdateStatement) parent;
return update.getTableName().getSimpleName();
} else if(parent instanceof SQLDeleteStatement) {
SQLDeleteStatement delete = (SQLDeleteStatement) parent;
return delete.getTableName().getSimpleName();
} else {
}
}
return "";
}
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:55,代码来源:MycatSchemaStatVisitor.java
示例6: main
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
public static void main(String[] args) {
String sql = " select * from event where eventId = 0001 and eventKey = key and eventName between begin and end";
String insert = " insert into uservalues(id,ooo)";
//使用mysql解析
MySqlStatementParser sqlStatementParser = new MySqlStatementParser(sql) ;
//解析select查询
// System.out.println("parse select "+sqlStatementParser.parseStatement());
SQLSelectStatement sqlStatement = (SQLSelectStatement) sqlStatementParser.parseStatement();
SQLSelect sqlSelect = sqlStatement.getSelect() ;
//获取sql查询块
SQLSelectQueryBlock sqlSelectQuery = (SQLSelectQueryBlock)sqlSelect.getQuery() ;
StringBuffer out = new StringBuffer() ;
// //创建sql解析的标准化输出
// SQLASTOutputVisitor sqlastOutputVisitor = SQLUtils.createFormatOutputVisitor(out , SQLUtils.parseStatements(sql, JdbcUtils.MYSQL) , JdbcUtils.MYSQL) ;
SQLBinaryOpExpr expr = (SQLBinaryOpExpr)sqlSelectQuery.getWhere();
System.out.println("expr:"+expr.getClass().getName());
// sqlastOutputVisitor.visit(expr);
SQLBetweenExpr betweenExpr = (SQLBetweenExpr) expr.getRight();
System.out.println(betweenExpr.getBeginExpr().toString());
// SQLIdentifierExpr sqlIdentifierExpr = (SQLIdentifierExpr) exprRight.getLeft();
// sqlIdentifierExpr.accept(sqlastOutputVisitor);
// List<Object> params = sqlVariantRefExpr.getName();
// System.out.println(sqlIdentifierExpr.getName());
int index = 0;
// for (TableStat.Column column:sqlastOutputVisitor.getgetColumns()){
// System.out.println(column.getName()+":"+params.get(index));
// index++;
// }
//
// //解析select项
// out.delete(0, out.length()) ;
// for (SQLSelectItem sqlSelectItem : sqlSelectQuery.getSelectList()) {
// if(out.length()>1){
// out.append(",") ;
// }
// sqlSelectItem.accept(sqlastOutputVisitor);
// }
// System.out.println("SELECT "+out) ;
//
// //解析from
// out.delete(0, out.length()) ;
// sqlSelectQuery.getFrom().accept(sqlastOutputVisitor) ;
// System.out.println("FROM "+out) ;
//
// //解析where
// out.delete(0, out.length()) ;
// sqlSelectQuery.getWhere().accept(sqlastOutputVisitor) ;
// System.out.println("WHERE "+out);
}
开发者ID:rpgmakervx,项目名称:slardar,代码行数:51,代码来源:SqlParserTest.java
示例7: visit
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public boolean visit(final SQLBetweenExpr x) {
parseResult.addCondition(x.getTestExpr(), Condition.BinaryOperator.BETWEEN, Arrays.asList(x.getBeginExpr(), x.getEndExpr()), getDatabaseType(), getParameters());
return super.visit(x);
}
开发者ID:balancebeam,项目名称:sherlock,代码行数:6,代码来源:AbstractPGSQLVisitor.java
示例8: visit
import com.alibaba.druid.sql.ast.expr.SQLBetweenExpr; //导入依赖的package包/类
@Override
public boolean visit(final SQLBetweenExpr x) {
parseResult.addCondition(x.getTestExpr(), BinaryOperator.BETWEEN, Arrays.asList(x.getBeginExpr(), x.getEndExpr()), getDatabaseType(), getParameters());
return super.visit(x);
}
开发者ID:balancebeam,项目名称:sherlock,代码行数:6,代码来源:AbstractOracleVisitor.java
注:本文中的com.alibaba.druid.sql.ast.expr.SQLBetweenExpr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论