Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        public override object Subtract(object a, object b, SqlType aType, SqlType otherType)
        {
            if ((a == null) || (b == null))
            {
                return(null);
            }
            switch (base.TypeCode)
            {
            case 0x65:
            case 0x66:
            case 0x6b:
            {
                IntervalMonthData data  = a as IntervalMonthData;
                IntervalMonthData data2 = b as IntervalMonthData;
                if ((data == null) || (data2 == null))
                {
                    TimestampData data3 = a as TimestampData;
                    TimestampData data4 = b as TimestampData;
                    if ((data3 == null) || (data4 == null))
                    {
                        throw Error.RuntimeError(0xc9, "IntervalType");
                    }
                    bool isYear = base.TypeCode == 0x65;
                    return(new IntervalMonthData((long)DateTimeType.SubtractMonths(data3, data4, isYear), this));
                }
                return(new IntervalMonthData(data.Units - data2.Units, this));
            }

            case 0x67:
            case 0x68:
            case 0x69:
            case 0x6a:
            case 0x6c:
            case 0x6d:
            case 110:
            case 0x6f:
            case 0x70:
            case 0x71:
            {
                IntervalSecondData data5 = a as IntervalSecondData;
                IntervalSecondData data6 = b as IntervalSecondData;
                if ((data5 == null) || (data6 == null))
                {
                    TimeData data7 = a as TimeData;
                    TimeData data8 = b as TimeData;
                    if ((data7 != null) && (data8 != null))
                    {
                        long num4 = data7.GetSeconds() - data8.GetSeconds();
                        return(new IntervalSecondData(num4, data7.GetNanos() - data8.GetNanos(), this, true));
                    }
                    TimestampData data9  = a as TimestampData;
                    TimestampData data10 = b as TimestampData;
                    if ((data9 != null) && (data10 != null))
                    {
                        long num6 = data9.GetSeconds() - data10.GetSeconds();
                        return(new IntervalSecondData(num6, data9.GetNanos() - data10.GetNanos(), this, true));
                    }
                    break;
                }
                long seconds = data5.Units - data6.Units;
                return(new IntervalSecondData(seconds, data5.Nanos - data6.Nanos, this, true));
            }
            }
            throw Error.RuntimeError(0xc9, "IntervalType");
        }