Search in sources :

Example 1 with CellAssignmentItem

use of com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause.CellAssignmentItem in project druid by alibaba.

the class OracleSelectParser method parseModelRulesClause.

private void parseModelRulesClause(MainModelClause mainModel) {
    ModelRulesClause modelRulesClause = new ModelRulesClause();
    if (identifierEquals("RULES")) {
        lexer.nextToken();
        if (lexer.token() == Token.UPDATE) {
            modelRulesClause.getOptions().add(ModelRuleOption.UPDATE);
            lexer.nextToken();
        } else if (identifierEquals("UPSERT")) {
            modelRulesClause.getOptions().add(ModelRuleOption.UPSERT);
            lexer.nextToken();
        }
        if (identifierEquals("AUTOMATIC")) {
            lexer.nextToken();
            accept(Token.ORDER);
            modelRulesClause.getOptions().add(ModelRuleOption.AUTOMATIC_ORDER);
        } else if (identifierEquals("SEQUENTIAL")) {
            lexer.nextToken();
            accept(Token.ORDER);
            modelRulesClause.getOptions().add(ModelRuleOption.SEQUENTIAL_ORDER);
        }
    }
    if (identifierEquals("ITERATE")) {
        lexer.nextToken();
        accept(Token.LPAREN);
        modelRulesClause.setIterate(expr());
        accept(Token.RPAREN);
        if (identifierEquals("UNTIL")) {
            lexer.nextToken();
            accept(Token.LPAREN);
            modelRulesClause.setUntil(expr());
            accept(Token.RPAREN);
        }
    }
    accept(Token.LPAREN);
    for (; ; ) {
        if (lexer.token() == Token.RPAREN) {
            lexer.nextToken();
            break;
        }
        CellAssignmentItem item = new CellAssignmentItem();
        if (lexer.token() == Token.UPDATE) {
            item.setOption(ModelRuleOption.UPDATE);
        } else if (identifierEquals("UPSERT")) {
            item.setOption(ModelRuleOption.UPSERT);
        }
        item.setCellAssignment(parseCellAssignment());
        item.setOrderBy(this.parseOrderBy());
        accept(Token.EQ);
        item.setExpr(expr());
        modelRulesClause.getCellAssignmentItems().add(item);
    }
    mainModel.setModelRulesClause(modelRulesClause);
}
Also used : CellAssignmentItem(com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause.CellAssignmentItem) ModelRulesClause(com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause.ModelRulesClause)

Aggregations

CellAssignmentItem (com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause.CellAssignmentItem)1 ModelRulesClause (com.alibaba.druid.sql.dialect.oracle.ast.clause.ModelClause.ModelRulesClause)1