use of com.alibaba.druid.sql.ast.expr.SQLSequenceExpr in project druid by alibaba.
the class DB2ExprParser method dotRest.
protected SQLExpr dotRest(SQLExpr expr) {
if (identifierEquals("NEXTVAL")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
SQLSequenceExpr seqExpr = new SQLSequenceExpr(identExpr, SQLSequenceExpr.Function.NextVal);
lexer.nextToken();
return seqExpr;
}
} else if (identifierEquals("PREVVAL")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
SQLSequenceExpr seqExpr = new SQLSequenceExpr(identExpr, SQLSequenceExpr.Function.PrevVal);
lexer.nextToken();
return seqExpr;
}
} else if (identifierEquals("CURRVAL")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
SQLSequenceExpr seqExpr = new SQLSequenceExpr(identExpr, SQLSequenceExpr.Function.CurrVal);
lexer.nextToken();
return seqExpr;
}
}
return super.dotRest(expr);
}
use of com.alibaba.druid.sql.ast.expr.SQLSequenceExpr in project druid by alibaba.
the class DB2ExprParser method primaryRest.
public SQLExpr primaryRest(SQLExpr expr) {
if (identifierEquals("VALUE")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
String ident = identExpr.getName();
if (ident.equalsIgnoreCase("NEXT")) {
lexer.nextToken();
accept(Token.FOR);
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.NextVal);
return seqExpr;
} else if (ident.equalsIgnoreCase("PREVIOUS")) {
lexer.nextToken();
accept(Token.FOR);
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.PrevVal);
return seqExpr;
}
}
} else if (identifierEquals("DATE")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
String ident = identExpr.getName();
if (ident.equalsIgnoreCase("CURRENT")) {
lexer.nextToken();
expr = new SQLIdentifierExpr("CURRENT DATE");
}
}
} else if (identifierEquals("TIMESTAMP")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
String ident = identExpr.getName();
if (ident.equalsIgnoreCase("CURRENT")) {
lexer.nextToken();
expr = new SQLIdentifierExpr("CURRENT DATE");
}
}
}
return super.primaryRest(expr);
}
use of com.alibaba.druid.sql.ast.expr.SQLSequenceExpr in project druid by alibaba.
the class OracleExprParser method dotRest.
protected SQLExpr dotRest(SQLExpr expr) {
if (lexer.token() == Token.LITERAL_ALIAS) {
String name = '"' + lexer.stringVal() + '"';
lexer.nextToken();
expr = new SQLPropertyExpr(expr, name);
if (lexer.token() == Token.DOT) {
lexer.nextToken();
expr = dotRest(expr);
}
return expr;
}
if (identifierEquals("NEXTVAL")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
SQLSequenceExpr seqExpr = new SQLSequenceExpr(identExpr, SQLSequenceExpr.Function.NextVal);
lexer.nextToken();
return seqExpr;
}
} else if (identifierEquals("CURRVAL")) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
SQLSequenceExpr seqExpr = new SQLSequenceExpr(identExpr, SQLSequenceExpr.Function.CurrVal);
lexer.nextToken();
return seqExpr;
}
}
return super.dotRest(expr);
}
Aggregations