use of com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlDeclareStatement in project druid by alibaba.
the class MySqlStatementParser method parseDeclare.
/**
* parse declare statement
*/
public MySqlDeclareStatement parseDeclare() {
MySqlDeclareStatement stmt = new MySqlDeclareStatement();
accept(Token.DECLARE);
// lexer.nextToken();
for (; ; ) {
SQLDeclareItem item = new SQLDeclareItem();
item.setName(exprParser.name());
stmt.addVar(item);
if (lexer.token() == Token.COMMA) {
accept(Token.COMMA);
continue;
} else if (lexer.token() != Token.EOF) {
// var type
item.setDataType(exprParser.parseDataType());
if (lexer.token() == Token.DEFAULT) {
lexer.nextToken();
SQLExpr defaultValue = this.exprParser.primary();
item.setValue(defaultValue);
}
break;
} else {
throw new ParserException("TODO");
}
}
return stmt;
}
Aggregations