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 repeatstatement implements SQLcontrolstatement { 12 13 public endinglabel _Optendinglabel0; 14 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442551; 15 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439222; 16 public searchcondition _searchcondition3; 17 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439224; 18 public SQLstatementlist _SQLstatementlist5; 19 public SNONRESERVEDWORD136444255 _SNONRESERVEDWORD1364442556; 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 _searchcondition3.getColumnDetails(); 36 _SQLstatementlist5.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 _SQLstatementlist5.setOuterControlStatement(this); 74 int aa = 1; 75 do { 76 Object listResult = _SQLstatementlist5.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 if (outerControlStatement == null) { 90 throw new DException("DSE8038", null); 91 } 92 SqlStatementListResult returningResult = new SqlStatementListResult(0); 93 returningResult.setResult(returningResultList.toArray()); 94 returningResult.setIterateLeaveResult(temp); 95 return returningResult; 96 } 97 } else { 98 returningResultList.add(result.getResult()); 99 } 100 } else if (listResult instanceof ReturnResult) { 101 return listResult; 102 } 103 } while (SearchConditionUtility.executeExpression(_searchcondition3, 104 searchConditionRefs, variableValues, serverSession).hashCode() != 0); 105 return returningResultList.toArray(); 106 } 107 108 public Object [] getParameters(Object object) throws DException { 109 ArrayList list = new ArrayList(); 110 Object [] par1 = _searchcondition3.getParameters(object); 111 if (par1 != null) { 112 list.addAll(Arrays.asList(par1)); 113 } 114 Object [] par2 = _SQLstatementlist5.getParameters(object); 115 if (par2 != null) { 116 list.addAll(Arrays.asList(par2)); 117 } 118 return list.toArray(); 119 } 120 121 148 149 public Object execute(_VariableValues variableValues) throws DException { 150 Object 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(_SNONRESERVEDWORD1364442556); 174 sb.append(" "); 175 sb.append(_SQLstatementlist5); 176 sb.append(" "); 177 sb.append(_SRESERVEDWORD12065439224); 178 sb.append(" "); 179 sb.append(_searchcondition3); 180 sb.append(" "); 181 sb.append(_SRESERVEDWORD12065439222); 182 sb.append(" "); 183 sb.append(_SNONRESERVEDWORD1364442551); 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(_searchcondition3.getColumnDetails(), _SQLstatementlist5.getColumnDetails()); 197 } 198 199 public _Reference[] checkSemantic(_ServerSession object) throws DException { 200 serverSession = object; 201 if (_searchcondition3.hasContainClause()) 202 throw new DException("DSE8138", null); 203 checkMatchingBeginningAndEndingLabel(serverSession); 204 ArrayList set = new ArrayList(); 205 searchConditionRefs = _searchcondition3.getReferences(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 _searchcondition3.getColumnDetails(); 216 _searchcondition3.checkSemantic(serverSession); 217 } catch (DException ex) { 218 if (!ex.getDseCode().equalsIgnoreCase("DSE4115")) { 219 throw ex; 220 } 221 } 222 _Reference[] par2 = _SQLstatementlist5.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 _searchcondition3.getTablesIncluded(aList); 231 } 232 233 public void getColumnsIncluded(ArrayList aList) throws DException { 234 _searchcondition3.getColumnsIncluded(aList); 235 } 236 } 237 | Popular Tags |