001package gudusoft.gsqlparser.stmt; 002 003 004import gudusoft.gsqlparser.*; 005import gudusoft.gsqlparser.nodes.TBlockSqlNode; 006import gudusoft.gsqlparser.nodes.TExceptionClause; 007import gudusoft.gsqlparser.nodes.TObjectName; 008import gudusoft.gsqlparser.nodes.TParseTreeVisitor; 009 010/** 011 * Base class for all sql statements that include multiple sql statements 012 */ 013public class TBlockSqlStatement extends TCustomSqlStatement { 014 015 016 protected TStatementList declareStatements = null; 017 protected TStatementList bodyStatements = null; 018 protected TExceptionClause exceptionClause = null; 019 020 021 public TBlockSqlStatement(EDbVendor dbvendor) { 022 super(dbvendor); 023 sqlstatementtype = ESqlStatementType.sst_block; 024 } 025 026 public TBlockSqlNode getBlockBody() { 027 return blockBody; 028 } 029 030 protected TBlockSqlNode blockBody = null; 031 032 public int doParseStatement(TCustomSqlStatement psql) { 033 super.doParseStatement(psql); 034 // blockBody.doParse(this,ESqlClause.unknown); 035 return 0; 036 } 037 038 public TObjectName getLabelName() { 039 if (blockBody == null){ 040 return super.getLabelName(); 041 }else 042 return blockBody.getLabelName(); 043 } 044 045 public String getLabelNameStr() { 046 if (getLabelName() != null){ 047 if (getLabelName().toString().endsWith(":")){ 048 return getLabelName().toString().substring(0,getLabelName().toString().length()-1); 049 }else{ 050 return getLabelName().toString(); 051 } 052 053 }else return ""; 054 } 055 056 public TObjectName getEndlabelName() 057 { 058 if (blockBody == null){ 059 return super.getEndlabelName(); 060 }else 061 return blockBody.getEndlabelName(); 062 } 063 064 public TExceptionClause getExceptionClause() 065 { 066 if (blockBody == null){ 067 return this.exceptionClause; 068 }else 069 return blockBody.getExceptionClause(); 070 } 071 072 public void setExceptionClause(TExceptionClause exceptionClause) { 073 if (this.blockBody == null){ 074 this.exceptionClause = exceptionClause; 075 }else 076 this.blockBody.setExceptionClause(exceptionClause); 077 } 078 079 public TStatementList getDeclareStatements() { 080 if (this.blockBody == null){ 081 if (this.declareStatements == null){ 082 this.declareStatements = new TStatementList(); 083 } 084 return this.declareStatements; 085 }else 086 return blockBody.getDeclareStatements(); 087 } 088 public void setDeclareStatements(TStatementList declareStatements) { 089 if (this.blockBody == null){ 090 this.declareStatements = declareStatements; 091 }else 092 this.blockBody.setDeclareStatements(declareStatements); 093 } 094 095 096 public TStatementList getBodyStatements() { 097 if (this.blockBody == null){ 098 if (this.bodyStatements == null){ 099 this.bodyStatements = new TStatementList(); 100 } 101 return this.bodyStatements; 102 }else 103 return blockBody.getBodyStatements(); 104 } 105 106 107 108 public void setBodyStatements(TStatementList bodyStatements) { 109 if (this.blockBody == null){ 110 this.bodyStatements = bodyStatements; 111 }else 112 this.blockBody.setBodyStatements(bodyStatements); 113 } 114 115}