use of com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput in project druid by alibaba.
the class SQLServerStatementParser method parseInsert0.
protected void parseInsert0(SQLInsertInto insert, boolean acceptSubQuery) {
SQLServerInsertStatement insertStatement = (SQLServerInsertStatement) insert;
SQLServerTop top = this.getExprParser().parseTop();
if (top != null) {
insertStatement.setTop(top);
}
if (lexer.token() == Token.INTO) {
lexer.nextToken();
}
SQLName tableName = this.exprParser.name();
insertStatement.setTableName(tableName);
if (lexer.token() == Token.LITERAL_ALIAS) {
insertStatement.setAlias(as());
}
parseInsert0_hinits(insertStatement);
if (lexer.token() == Token.IDENTIFIER && !lexer.stringVal().equalsIgnoreCase("OUTPUT")) {
insertStatement.setAlias(lexer.stringVal());
lexer.nextToken();
}
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
this.exprParser.exprList(insertStatement.getColumns(), insertStatement);
accept(Token.RPAREN);
}
SQLServerOutput output = this.getExprParser().parserOutput();
if (output != null) {
insertStatement.setOutput(output);
}
if (lexer.token() == Token.VALUES) {
lexer.nextToken();
for (; ; ) {
accept(Token.LPAREN);
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
this.exprParser.exprList(values.getValues(), values);
insertStatement.getValuesList().add(values);
accept(Token.RPAREN);
if (!parseCompleteValues && insertStatement.getValuesList().size() >= parseValuesSize) {
lexer.skipToEOF();
break;
}
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
} else {
break;
}
}
} else if (acceptSubQuery && (lexer.token() == Token.SELECT || lexer.token() == Token.LPAREN)) {
SQLQueryExpr queryExpr = (SQLQueryExpr) this.exprParser.expr();
insertStatement.setQuery(queryExpr.getSubQuery());
} else if (lexer.token() == Token.DEFAULT) {
lexer.nextToken();
accept(Token.VALUES);
insertStatement.setDefaultValues(true);
}
}
use of com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput in project druid by alibaba.
the class SQLServerExprParser method parserOutput.
protected SQLServerOutput parserOutput() {
if (identifierEquals("OUTPUT")) {
lexer.nextToken();
SQLServerOutput output = new SQLServerOutput();
final List<SQLSelectItem> selectList = output.getSelectList();
for (; ; ) {
final SQLSelectItem selectItem = parseSelectItem();
selectList.add(selectItem);
if (lexer.token() != Token.COMMA) {
break;
}
lexer.nextToken();
}
if (lexer.token() == Token.INTO) {
lexer.nextToken();
output.setInto(new SQLExprTableSource(this.name()));
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
this.exprList(output.getColumns(), output);
accept(Token.RPAREN);
}
}
return output;
}
return null;
}
use of com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput in project druid by alibaba.
the class SQLServerStatementParser method parseUpdateStatement.
public SQLUpdateStatement parseUpdateStatement() {
SQLServerUpdateStatement udpateStatement = createUpdateStatement();
accept(Token.UPDATE);
SQLServerTop top = this.getExprParser().parseTop();
if (top != null) {
udpateStatement.setTop(top);
}
SQLTableSource tableSource = this.exprParser.createSelectParser().parseTableSource();
udpateStatement.setTableSource(tableSource);
parseUpdateSet(udpateStatement);
SQLServerOutput output = this.getExprParser().parserOutput();
if (output != null) {
udpateStatement.setOutput(output);
}
if (lexer.token() == Token.FROM) {
lexer.nextToken();
SQLTableSource from = this.exprParser.createSelectParser().parseTableSource();
udpateStatement.setFrom(from);
}
if (lexer.token() == (Token.WHERE)) {
lexer.nextToken();
udpateStatement.setWhere(this.exprParser.expr());
}
return udpateStatement;
}
Aggregations