001package gudusoft.gsqlparser.stmt; 002 003import gudusoft.gsqlparser.*; 004import gudusoft.gsqlparser.nodes.TExpression; 005import gudusoft.gsqlparser.nodes.TObjectName; 006import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 007 008/** 009 * The EXIT statement exits a loop and transfers control to the end of the loop. 010 * The EXIT statement has two forms: the unconditional EXIT and the conditional EXIT WHEN. 011 */ 012public class TExitStmt extends TCustomSqlStatement { 013 public TExitStmt(){ 014 this(EDbVendor.dbvoracle); 015 } 016 017 public TExitStmt(EDbVendor dbvendor){ 018 super(dbvendor); 019 sqlstatementtype = ESqlStatementType.sst_exitstmt; 020 } 021 022 void buildsql() { 023 } 024 025 void clear() { 026 } 027 028 String getasprettytext() { 029 return ""; 030 } 031 032 void iterate(TVisitorAbs pvisitor) { 033 } 034 035 public void setExitlabelName(TObjectName exitlabelName) { 036 this.exitlabelName = exitlabelName; 037 } 038 039 public TObjectName getExitlabelName() { 040 041 return exitlabelName; 042 } 043 044 private TObjectName exitlabelName; 045 046 private TExpression whenCondition = null; 047 048 /** 049 * Valid only in the conditional EXIT WHEN. 050 * @return If and only if the value of this expression is TRUE, 051 * the current loop (or the loop labeled by label_name) is exited immediately. 052 */ 053 public TExpression getWhenCondition() { 054 return whenCondition; 055 } 056 057 public void init(Object arg1) 058 { 059 whenCondition = (TExpression)arg1; 060 } 061 062 public int doParseStatement(TCustomSqlStatement psql) { 063 super.doParseStatement(psql); 064 if (whenCondition != null){ 065 whenCondition.doParse(this,ESqlClause.unknown); 066 } 067 return 0; 068 } 069 070 public void accept(TParseTreeVisitor v){ 071 v.preVisit(this); 072 v.postVisit(this); 073 } 074 075 public void acceptChildren(TParseTreeVisitor v){ 076 v.preVisit(this); 077 v.postVisit(this); 078 } 079 080 public void setWhenCondition(TExpression whenCondition) { 081 this.whenCondition = whenCondition; 082 } 083}