Search in sources :

Example 1 with SQLServerUpdateStatement

use of com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerUpdateStatement 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;
}
Also used : SQLServerTop(com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop) SQLServerUpdateStatement(com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerUpdateStatement) SQLServerOutput(com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput)

Aggregations

SQLServerOutput (com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerOutput)1 SQLServerTop (com.alibaba.druid.sql.dialect.sqlserver.ast.SQLServerTop)1 SQLServerUpdateStatement (com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerUpdateStatement)1