Beispiel #1
0
        public virtual long Position(ISessionInterface session, object data, object otherData, SqlType otherType, long offset)
        {
            if ((data == null) || (otherData == null))
            {
                return(-1L);
            }
            string str = (string)data;

            if (otherType.TypeCode == 40)
            {
                IClobData data2 = (IClobData)otherData;
                long      num2  = data2.Length(session);
                if ((offset + num2) > str.Length)
                {
                    return(-1L);
                }
                string str2 = data2.GetSubString(session, 0L, (int)num2);
                return((long)str.IndexOf(str2, (int)offset));
            }
            if (!otherType.IsCharacterType())
            {
                throw Error.RuntimeError(0xc9, "CharacterType");
            }
            string str3   = (string)otherData;
            long   length = str3.Length;

            if ((offset + length) > str.Length)
            {
                return(-1L);
            }
            return(str.IndexOf(str3, (int)offset));
        }
Beispiel #2
0
 public override object ConvertToTypeAdo(ISessionInterface session, object a, SqlType otherType)
 {
     if (a == null)
     {
         return(a);
     }
     if (otherType.TypeCode == 0x10)
     {
         return(a);
     }
     if (otherType.IsLobType())
     {
         throw Error.GetError(0x15b9);
     }
     if (otherType.IsCharacterType())
     {
         if ("0".Equals(a))
         {
             return(true);
         }
         if ("1".Equals(a))
         {
             return(false);
         }
     }
     return(this.ConvertToType(session, a, otherType));
 }
Beispiel #3
0
 public override bool CanConvertFrom(SqlType othType)
 {
     if (((othType.TypeCode != 0) && !othType.IsBooleanType()) && !othType.IsCharacterType())
     {
         return(othType.IsIntegralType());
     }
     return(true);
 }
Beispiel #4
0
        public override SqlType GetAggregateType(SqlType other)
        {
            if (base.TypeCode == other.TypeCode)
            {
                if (base.Precision < other.Precision)
                {
                    return(other);
                }
                return(this);
            }
            if (other.IsCharacterType())
            {
                return(other.GetAggregateType(this));
            }
            switch (other.TypeCode)
            {
            case 30:
                if (other.Precision < base.Precision)
                {
                    return(GetBinaryType(other.TypeCode, base.Precision));
                }
                return(other);

            case 60:
                if (base.Precision < other.Precision)
                {
                    return(GetBinaryType(base.TypeCode, other.Precision));
                }
                return(this);

            case 0x3d:
                if (base.TypeCode != 30)
                {
                    if (other.Precision < base.Precision)
                    {
                        return(GetBinaryType(other.TypeCode, base.Precision));
                    }
                    return(other);
                }
                if (base.Precision < other.Precision)
                {
                    return(GetBinaryType(base.TypeCode, other.Precision));
                }
                return(this);

            case -11:
                if (base.Precision < 0x10L)
                {
                    return(GetBinaryType(base.TypeCode, 0x10L));
                }
                return(this);

            case 0:
                return(this);
            }
            throw Error.GetError(0x15ba);
        }
Beispiel #5
0
 public override SqlType GetAggregateType(SqlType other)
 {
     if (base.TypeCode == other.TypeCode)
     {
         return(this);
     }
     if (!other.IsCharacterType() && !other.IsNumberType())
     {
         throw Error.GetError(0x15ba);
     }
     return(other.GetAggregateType(this));
 }
Beispiel #6
0
        public override long Position(ISessionInterface session, object data, object otherData, SqlType otherType, long start)
        {
            IClobData data2 = (IClobData)data;

            if (otherType.TypeCode == 40)
            {
                return(data2.Position(session, (IClobData)otherData, start));
            }
            if (!otherType.IsCharacterType())
            {
                throw Error.RuntimeError(0xc9, "ClobType");
            }
            return(data2.Position(session, (string)otherData, start));
        }
Beispiel #7
0
        public override SqlType GetAggregateType(SqlType other)
        {
            SqlType type3;

            if (base.TypeCode == other.TypeCode)
            {
                if ((base.Precision >= other.Precision) && (base.Scale >= other.Scale))
                {
                    return(this);
                }
                if ((base.Precision <= other.Precision) && (base.Scale <= other.Scale))
                {
                    return(other);
                }
            }
            if (other == SqlType.SqlAllTypes)
            {
                return(this);
            }
            if (other.IsCharacterType())
            {
                return(other.GetAggregateType(this));
            }
            if (!other.IsIntervalType())
            {
                throw Error.GetError(0x15ba);
            }
            IntervalType type2                = (IntervalType)other;
            int          startType            = (type2.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type2.StartIntervalType;
            int          endType              = (type2.EndIntervalType > base.EndIntervalType) ? type2.EndIntervalType : base.EndIntervalType;
            int          combinedIntervalType = GetCombinedIntervalType(startType, endType);
            long         precision            = (base.Precision > other.Precision) ? base.Precision : other.Precision;
            int          fractionPrecision    = (base.Scale > other.Scale) ? base.Scale : other.Scale;

            try
            {
                type3 = GetIntervalType(combinedIntervalType, startType, endType, precision, fractionPrecision, false);
            }
            catch (Exception)
            {
                throw Error.GetError(0x15ba);
            }
            return(type3);
        }
Beispiel #8
0
        public override SqlType GetAggregateType(SqlType other)
        {
            int num2;

            if (base.TypeCode == other.TypeCode)
            {
                if (base.Scale < other.Scale)
                {
                    return(other);
                }
                return(this);
            }
            if (other.TypeCode == 0)
            {
                return(this);
            }
            if (other.IsCharacterType())
            {
                return(other.GetAggregateType(this));
            }
            if (!other.IsDateTimeType())
            {
                throw Error.GetError(0x15ba);
            }
            DateTimeType type2 = (DateTimeType)other;

            if ((type2.StartIntervalType > base.EndIntervalType) || (base.StartIntervalType > type2.EndIntervalType))
            {
                throw Error.GetError(0x15ba);
            }
            int  scale = (base.Scale > type2.Scale) ? base.Scale : type2.Scale;
            bool flag  = this._withTimeZone || type2._withTimeZone;

            if (((type2.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type2.StartIntervalType) == 0x68)
            {
                num2 = flag ? 0x5e : 0x5c;
            }
            else
            {
                num2 = flag ? 0x5f : 0x5d;
            }
            return(GetDateTimeType(num2, scale));
        }
Beispiel #9
0
 public override bool CanConvertFrom(SqlType othType)
 {
     if (othType.TypeCode == 0)
     {
         return(true);
     }
     if (othType.IsCharacterType())
     {
         return(true);
     }
     if (!othType.IsDateTimeType())
     {
         return(false);
     }
     if (othType.TypeCode == 0x5b)
     {
         return(base.TypeCode != 0x5c);
     }
     return((othType.TypeCode != 0x5c) || (base.TypeCode != 0x5b));
 }
Beispiel #10
0
        public override int PrecedenceDegree(SqlType other)
        {
            if (other.TypeCode == base.TypeCode)
            {
                return(0);
            }
            if (!other.IsCharacterType())
            {
                return(-2147483648);
            }
            switch (base.TypeCode)
            {
            case 40:
                if (other.TypeCode != 1)
                {
                    return(-2);
                }
                return(-4);

            case 100:
            case 12:
                if ((other.TypeCode == 12) || (other.TypeCode == 100))
                {
                    return(0);
                }
                if (other.TypeCode != 40)
                {
                    return(2);
                }
                return(4);

            case 1:
                if (other.TypeCode != 40)
                {
                    return(2);
                }
                return(4);
            }
            throw Error.RuntimeError(0xc9, "CharacterType");
        }
Beispiel #11
0
 public override bool CanConvertFrom(SqlType othType)
 {
     return((((othType.TypeCode == 0) || othType.IsCharacterType()) || othType.IsNumberType()) || (othType.IsIntervalType() && (this.IsYearMonthIntervalType() == ((IntervalType)othType).IsYearMonthIntervalType())));
 }
Beispiel #12
0
 public override bool CanConvertFrom(SqlType othType)
 {
     return((((othType.TypeCode == 0) || othType.IsGuidType()) || othType.IsCharacterType()) || (othType.IsBinaryType() && (othType.Precision == 0x10L)));
 }