oracle sql parser support pl/sql case statement.

This commit is contained in:
wenshao
2017-05-11 16:05:19 +08:00
parent 5693b8f2e9
commit c29edde460
6 changed files with 371 additions and 5 deletions
@@ -496,6 +496,43 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
return false;
}
public boolean visit(SQLCaseStatement x) {
print0(ucase ? "CASE" : "case");
if (x.getValueExpr() != null) {
print(' ');
x.getValueExpr().accept(this);
}
incrementIndent();
println();
printlnAndAccept(x.getItems(), " ");
if (x.getElseStatements() != null) {
println();
print0(ucase ? "ELSE " : "else ");
printlnAndAccept(x.getElseStatements(), ";");
print(';');
}
decrementIndent();
println();
print0(ucase ? "END CASE" : "end case");
return false;
}
public boolean visit(SQLCaseStatement.Item x) {
print0(ucase ? "WHEN " : "when ");
x.getConditionExpr().accept(this);
print0(ucase ? " THEN " : " then ");
SQLStatement stmt = x.getStatement();
if (stmt != null) {
stmt.accept(this);
print(';');
}
return false;
}
public boolean visit(SQLCastExpr x) {
print0(ucase ? "CAST(" : "cast(");
x.getExpr().accept(this);
@@ -31,6 +31,10 @@ public interface SQLASTVisitor {
void endVisit(SQLCaseExpr.Item x);
void endVisit(SQLCaseStatement x);
void endVisit(SQLCaseStatement.Item x);
void endVisit(SQLCharExpr x);
void endVisit(SQLIdentifierExpr x);
@@ -71,6 +75,10 @@ public interface SQLASTVisitor {
boolean visit(SQLCaseExpr.Item x);
boolean visit(SQLCaseStatement x);
boolean visit(SQLCaseStatement.Item x);
boolean visit(SQLCastExpr x);
boolean visit(SQLCharExpr x);
@@ -39,6 +39,12 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
public void endVisit(SQLCaseExpr.Item x) {
}
public void endVisit(SQLCaseStatement x) {
}
public void endVisit(SQLCaseStatement.Item x) {
}
public void endVisit(SQLCharExpr x) {
}
@@ -104,6 +110,14 @@ public class SQLASTVisitorAdapter implements SQLASTVisitor {
return true;
}
public boolean visit(SQLCaseStatement x) {
return true;
}
public boolean visit(SQLCaseStatement.Item x) {
return true;
}
public boolean visit(SQLCastExpr x) {
return true;
}