1 package com.daffodilwoods.daffodildb.server.sql99.dcl.sqlcontrolstatement; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.sql99.common.*; 7 import com.daffodilwoods.daffodildb.server.sql99.token.*; 8 import com.daffodilwoods.daffodildb.server.sql99.utils.*; 9 import com.daffodilwoods.database.resource.*; 10 11 public class whilestatement implements SQLcontrolstatement { 12 13 public endinglabel _Optendinglabel0; 14 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439221; 15 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 16 public SQLstatementlist _SQLstatementlist3; 17 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439224; 18 public searchcondition _searchcondition5; 19 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439226; 20 public beginninglabelScolon94842719 _OptbeginninglabelScolon948427197; 21 22 private SQLcontrolstatement outerControlStatement; 23 private String beginningLabel; 24 private _Reference[] searchConditionRefs; 25 private _ServerSession serverSession; 26 27 public void setOuterControlStatement(SQLcontrolstatement outerst) { 28 outerControlStatement = outerst; 29 } 30 31 public Object run(Object object) throws DException { 32 _StatementExecutionContext sec = (_StatementExecutionContext) object; 33 _ServerSession serverSession = sec.getServerSession(); 34 checkSystax(serverSession); 35 _searchcondition5.getColumnDetails(); 36 _SQLstatementlist3.run(object); 37 return this; 38 } 39 40 private void checkSystax(_ServerSession serverSession) throws DException { 41 checkMatchingBeginningAndEndingLabel(serverSession); 42 if (_OptbeginninglabelScolon948427197 == null) { assignImplicitBeginningLabel(); 44 } else { 45 beginningLabel = "@" + 46 (String ) _OptbeginninglabelScolon948427197.getIdentifier(); 47 } 48 scopeManagement(serverSession); 49 } 50 51 private void checkMatchingBeginningAndEndingLabel(_ServerSession 52 serverSession) throws DException { 53 if (_Optendinglabel0 != null) { 54 if (_OptbeginninglabelScolon948427197 == null) { 55 throw new DException("DSE8036", null); 56 } 57 else if (! ( (String ) _Optendinglabel0.getIdentifier()).equalsIgnoreCase 58 ( (String ) _OptbeginninglabelScolon948427197.getIdentifier())) { 59 throw new DException("DSE8037", null); 60 } 61 } 62 } 63 64 private void scopeManagement(_ServerSession serverSession) throws DException { 65 } 66 67 private void assignImplicitBeginningLabel() throws DException { 68 beginningLabel = "@internalLabel" + this.hashCode(); 69 } 70 71 private Object executeStatements(_VariableValues variableValues) throws DException { 72 ArrayList returningResultList = new ArrayList(); 73 _SQLstatementlist3.setOuterControlStatement(this); 74 while (SearchConditionUtility.executeExpression(_searchcondition5, 75 searchConditionRefs, variableValues, serverSession).hashCode() == 0) { 76 Object listResult = _SQLstatementlist3.execute(variableValues); 77 if (listResult instanceof SqlStatementListResult) { 78 SqlStatementListResult result = (SqlStatementListResult) listResult; 79 if (result.hasIterateLeaveResult()) { 80 IterateLeaveResult temp = result.getIterateLeaveResult(); 81 if (temp.getLabel().equalsIgnoreCase(beginningLabel)) { 82 returningResultList.add(result.getResult()); 83 if (temp.getType() == IterateLeaveResult.ITERATETYPE) { 84 continue; 85 } else if (temp.getType() == IterateLeaveResult.LEAVETYPE) { 86 break; 87 } 88 } else { 89 SqlStatementListResult returningResult = new SqlStatementListResult(0); 90 returningResult.setResult(returningResultList.toArray()); 91 returningResult.setIterateLeaveResult(temp); 92 if (outerControlStatement == null) { 93 throw new DException("DSE8038", null); 94 } 95 return returningResult; 96 } 97 } else { 98 returningResultList.add(result.getResult()); 99 } 100 } else if (listResult instanceof ReturnResult) { 101 return listResult; 102 } 103 } 104 return returningResultList.toArray(); 105 } 106 107 public Object [] getParameters(Object object) throws DException { 108 ArrayList list = new ArrayList(); 109 Object [] par1 = _searchcondition5.getParameters(object); 110 if (par1 != null) { 111 list.addAll(Arrays.asList(par1)); 112 } 113 Object [] par2 = _SQLstatementlist3.getParameters(object); 114 if (par2 != null) { 115 list.addAll(Arrays.asList(par2)); 116 } 117 return list.toArray(); 118 } 119 120 147 148 public Object execute(_VariableValues variableValues) throws DException { 149 Object result = null; 150 result = executeStatements(variableValues); 151 return result; 152 } 153 154 public Object execute(Object [] values) throws DException { 155 throw new UnsupportedOperationException (); 156 } 157 158 public Object executeForFresh(Object [] values) throws DException { 159 throw new UnsupportedOperationException (); 160 } 161 162 public ParameterInfo[] getParameterInfo() throws DException { 163 throw new UnsupportedOperationException (); 164 } 165 166 public String toString() { 167 StringBuffer sb = new StringBuffer (); 168 sb.append(" "); 169 if (_OptbeginninglabelScolon948427197 != null) { 170 sb.append(_OptbeginninglabelScolon948427197); 171 } 172 sb.append(" "); 173 sb.append(_SRESERVEDWORD12065439226); 174 sb.append(" "); 175 sb.append(_searchcondition5); 176 sb.append(" "); 177 sb.append(_SRESERVEDWORD12065439224); 178 sb.append(" "); 179 sb.append(_SQLstatementlist3); 180 sb.append(" "); 181 sb.append(_SRESERVEDWORD12065439222); 182 sb.append(" "); 183 sb.append(_SRESERVEDWORD12065439221); 184 sb.append(" "); 185 if (_Optendinglabel0 != null) { 186 sb.append(_Optendinglabel0); 187 } 188 return sb.toString().trim(); 189 } 190 191 public Object clone() throws CloneNotSupportedException { 192 return this; 193 } 194 195 public ColumnDetails[] getColumnDetails() throws DException { 196 return GeneralPurposeStaticClass.getJointColumnDetails(_searchcondition5.getColumnDetails(), _SQLstatementlist3.getColumnDetails()); 197 } 198 199 public _Reference[] checkSemantic(_ServerSession object) throws DException { 200 serverSession = object; 201 if (_searchcondition5.hasContainClause()) 202 throw new DException("DSE8138", null); 203 checkMatchingBeginningAndEndingLabel(serverSession); 204 ArrayList set = new ArrayList(); 205 searchConditionRefs = _searchcondition5.getReferences(SQLcontrolstatement.dummyTableDetail); 206 if (searchConditionRefs != null) { 207 for (int i = 0; i < searchConditionRefs.length; i++) { 208 if (searchConditionRefs[i].getReferenceType() != SimpleConstants.SUBQUERY) 209 set.add(searchConditionRefs[i]); 210 } 211 } 212 214 try { 215 _searchcondition5.getColumnDetails(); 216 _searchcondition5.checkSemantic(serverSession); 217 } catch (DException ex) { 218 if (!ex.getDseCode().equalsIgnoreCase("DSE4115")) { 219 throw ex; 220 } 221 } 222 _Reference[] par2 = _SQLstatementlist3.checkSemantic(object); 223 if (par2 != null) { 224 set.addAll(Arrays.asList(par2)); 225 } 226 return (_Reference[]) set.toArray(new _Reference[0]); 227 } 228 229 public void getTableIncluded(ArrayList aList) throws DException { 230 _searchcondition5.getTablesIncluded(aList); 231 } 232 233 public void getColumnsIncluded(ArrayList aList) throws DException { 234 _searchcondition5.getColumnsIncluded(aList); 235 } 236 } 237 | Popular Tags |