private object MultiplyOrDivide(object a, object b, bool divide) { decimal units; if ((a == null) || (b == null)) { return(null); } if (a is ValueType) { a = b; b = a; } if (divide && NumberType.IsZero(b)) { throw Error.GetError(0xd68); } NumberType type = NumberType.GetNumberType(3, 40L, 9); decimal num = Convert.ToDecimal(type.ConvertToDefaultType(null, b)); if (this._isYearMonth) { units = ((IntervalMonthData)a).Units; } else { IntervalSecondData data = (IntervalSecondData)a; units = data.Units + (data.Nanos / DTIType.NanoScaleFactors[0]); } decimal result = divide ? ((decimal)type.Divide(units, num, SqlType.SqlDecimal, SqlType.SqlDecimal)) : ((decimal)type.Multiply(units, num, SqlType.SqlDecimal, SqlType.SqlDecimal)); if (!NumberType.IsInLongLimits(result)) { throw Error.GetError(0xd6b); } if (this._isYearMonth) { return(new IntervalMonthData((long)result, this)); } int num4 = (int)NumberType.ScaledDecimal(result, 9); return(new IntervalSecondData((long)result, (long)num4, this, true)); }
public static SqlType GetDataType(int type, int collation, long precision, int scale) { if (type <= 0x19) { if (type > 12) { if (type == 0x10) { return(SqlBoolean); } if (type == 0x19) { return(SqlBigint); } } else { switch (type) { case -11: return(SqlUniqueIdentifier); case -6: return(Tinyint); case 0: return(SqlAllTypes); case 1: case 12: goto Label_0191; case 2: case 3: if (precision == 0) { precision = 0x7fffffffL; } return(NumberType.GetNumberType(type, precision, scale)); case 4: return(SqlInteger); case 5: return(SqlSmallint); case 6: if (precision > 0x35L) { throw Error.GetError(0x15d8, precision); } goto Label_0175; case 7: case 8: goto Label_0175; } } goto Label_0199; } if (type <= 40) { if (type == 30) { goto Label_00B5; } if (type == 40) { goto Label_0191; } goto Label_0199; } if ((type - 60) > 1) { switch (type) { case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: return(DateTimeType.GetDateTimeType(type, scale)); case 100: goto Label_0191; case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 110: case 0x6f: case 0x70: case 0x71: return(IntervalType.GetIntervalType(type, precision, scale)); case 0x457: return(Other); } goto Label_0199; } Label_00B5: return(BinaryType.GetBinaryType(type, precision)); Label_0175: return(SqlDouble); Label_0191: return(CharacterType.GetCharacterType(type, precision)); Label_0199: throw Error.RuntimeError(0xc9, "Type"); }