}
public SQLStatement parseCreateTrigger() {
accept(Token.TRIGGER);
SQLCreateTriggerStatement stmt = new SQLCreateTriggerStatement(getDbType());
stmt.setName(this.exprParser.name());
if (identifierEquals("BEFORE")) {
stmt.setTriggerType(TriggerType.BEFORE);
lexer.nextToken();
} else if (identifierEquals("AFTER")) {
stmt.setTriggerType(TriggerType.AFTER);
lexer.nextToken();
} else if (identifierEquals("INSTEAD")) {
lexer.nextToken();
accept(Token.OF);
stmt.setTriggerType(TriggerType.INSTEAD_OF);
}
for (;;) {
if (lexer.token() == Token.INSERT) {
lexer.nextToken();
stmt.getTriggerEvents().add(TriggerEvent.INSERT);
continue;
}
if (lexer.token() == Token.UPDATE) {
lexer.nextToken();
stmt.getTriggerEvents().add(TriggerEvent.UPDATE);
continue;
}
if (lexer.token() == Token.DELETE) {
lexer.nextToken();
stmt.getTriggerEvents().add(TriggerEvent.DELETE);
continue;
}
break;
}
accept(Token.ON);
stmt.setOn(this.exprParser.name());
if (lexer.token() == Token.FOR) {
lexer.nextToken();
acceptIdentifier("EACH");
accept(Token.ROW);
stmt.setForEachRow(true);
}
SQLStatement body = this.parseBlock();
stmt.setBody(body);
return stmt;
}