1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.error.StandardException; 25 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 28 import org.apache.derby.iapi.types.DataValueDescriptor; 29 import org.apache.derby.catalog.types.UserDefinedTypeIdImpl; 30 31 import org.apache.derby.iapi.services.context.ContextManager; 32 import org.apache.derby.iapi.services.context.Context; 33 34 import org.apache.derby.iapi.jdbc.ConnectionContext; 35 36 import org.apache.derby.iapi.types.DataValueFactory; 37 import org.apache.derby.iapi.types.TypeId; 38 39 import org.apache.derby.iapi.sql.execute.ExecutionContext; 40 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 41 42 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext; 43 import org.apache.derby.iapi.store.access.TransactionController; 44 import org.apache.derby.iapi.reference.Attribute; 45 46 import org.apache.derby.iapi.sql.ResultSet; 47 48 import java.sql.Connection ; 49 import java.sql.SQLException ; 50 51 57 public abstract class BaseExpressionActivation 58 { 59 60 61 BaseExpressionActivation() 65 { 66 super(); 67 } 68 69 70 87 public static DataValueDescriptor minValue(DataValueDescriptor v1, 88 DataValueDescriptor v2, 89 DataValueDescriptor v3, 90 DataValueDescriptor v4, 91 int judgeTypeFormatId, 92 int judgeUserJDBCTypeId) 93 throws StandardException 94 { 95 DataValueDescriptor judge; 96 if (judgeUserJDBCTypeId == -1) 97 judge = (DataValueDescriptor) new TypeId(judgeTypeFormatId, null).getNull(); 98 else 99 judge = (DataValueDescriptor) new TypeId(judgeTypeFormatId, new UserDefinedTypeIdImpl()).getNull(); 100 101 DataValueDescriptor minVal = v1; 102 if (v2 != null && judge.lessThan(v2, minVal).equals(true)) 103 minVal = v2; 104 if (v3 != null && judge.lessThan(v3, minVal).equals(true)) 105 minVal = v3; 106 if (v4 != null && judge.lessThan(v4, minVal).equals(true)) 107 minVal = v4; 108 return minVal; 109 } 110 111 112 129 public static DataValueDescriptor maxValue(DataValueDescriptor v1, 130 DataValueDescriptor v2, 131 DataValueDescriptor v3, 132 DataValueDescriptor v4, 133 int judgeTypeFormatId, 134 int judgeUserJDBCTypeId) 135 throws StandardException 136 { 137 DataValueDescriptor judge; 138 if (judgeUserJDBCTypeId == -1) 139 judge = new TypeId(judgeTypeFormatId, null).getNull(); 140 else 141 judge = new TypeId(judgeTypeFormatId, new UserDefinedTypeIdImpl()).getNull(); 142 143 DataValueDescriptor maxVal = v1; 144 if (v2 != null && judge.greaterThan(v2, maxVal).equals(true)) 145 maxVal = v2; 146 if (v3 != null && judge.greaterThan(v3, maxVal).equals(true)) 147 maxVal = v3; 148 if (v4 != null && judge.greaterThan(v4, maxVal).equals(true)) 149 maxVal = v4; 150 return maxVal; 151 } 152 153 } 154 | Popular Tags |