public OracleNumber(OracleNumber from)
 {
     byte[] buffer = from._value;
     if (buffer != null)
     {
         this._value = (byte[]) buffer.Clone();
     }
     else
     {
         this._value = null;
     }
 }
		public OracleNumber (OracleNumber from)
			: this (from.Value)
		{
		}
		public static OracleNumber Subtract (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (x.Value - y.Value);
		}
		public static OracleNumber Round (OracleNumber n, int position)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Round (n.Value, position));
		}
		public static OracleBoolean NotEquals (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value != y.Value);
		}
		public static OracleNumber Multiply (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (x.Value * y.Value);
		}
		public static OracleNumber Min (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Min (x.Value, y.Value));
		}
		public static OracleNumber Log (OracleNumber n, OracleNumber newBase)
		{
			if (n.IsNull || newBase.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Log ((double) n, (double) newBase));
		}
 public static OracleNumber Log(OracleNumber n, OracleNumber newBase)
 {
     if (n.IsNull || newBase.IsNull)
     {
         return Null;
     }
     OracleConnection.ExecutePermission.Demand();
     OciErrorHandle errorHandle = TempEnvironment.GetErrorHandle();
     OracleNumber number = new OracleNumber(false);
     int rc = System.Data.Common.UnsafeNativeMethods.OCINumberLog(errorHandle, newBase._value, n._value, number._value);
     if (rc != 0)
     {
         OracleException.Check(errorHandle, rc);
     }
     return number;
 }
 public static OracleNumber Log(OracleNumber n, int newBase)
 {
     return Log(n, new OracleNumber(newBase));
 }
 public static OracleBoolean LessThanOrEqual(OracleNumber x, OracleNumber y)
 {
     return (x <= y);
 }
 public static OracleBoolean LessThan(OracleNumber x, OracleNumber y)
 {
     return (x < y);
 }
 public static OracleBoolean GreaterThanOrEqual(OracleNumber x, OracleNumber y)
 {
     return (x >= y);
 }
 public static OracleBoolean GreaterThan(OracleNumber x, OracleNumber y)
 {
     return (x > y);
 }
		public static OracleNumber Acos (OracleNumber n)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Acos ((double) n));
		}
Esempio n. 16
0
 public static OracleBoolean GreaterThanOrEqual(OracleNumber x, OracleNumber y)
 {
     return(x >= y);
 }
        internal int PutOracleValue(object value, NativeBuffer buffer, int bufferOffset, MetaType metaType, OracleConnection connection, ref SafeHandle handleToBind)
        {
            handleToBind = null;
            OCI.DATATYPE    ociType   = metaType.OciType;
            OracleParameter parameter = this.Parameter;

            switch (ociType)
            {
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
            case OCI.DATATYPE.CHAR:
                return(OracleString.MarshalToNative(value, parameter.Offset, parameter.GetActualSize(), buffer, bufferOffset, ociType, this._bindAsUCS2));

            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.UNSIGNEDINT:
                buffer.StructureToPtr(bufferOffset, value);
                return(metaType.BindSize);

            case OCI.DATATYPE.VARNUM:
                return(OracleNumber.MarshalToNative(value, buffer, bufferOffset, connection));

            case OCI.DATATYPE.DATE:
                return(OracleDateTime.MarshalDateToNative(value, buffer, bufferOffset, ociType, connection));

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
            {
                int    num;
                byte[] buffer2;
                if (this._coercedValue is OracleBinary)
                {
                    OracleBinary binary = (OracleBinary)this._coercedValue;
                    buffer2 = binary.Value;
                }
                else
                {
                    buffer2 = (byte[])this._coercedValue;
                }
                int num2       = buffer2.Length - parameter.Offset;
                int actualSize = parameter.GetActualSize();
                if (actualSize != 0)
                {
                    num2 = Math.Min(num2, actualSize);
                }
                if (OCI.DATATYPE.LONGVARRAW == ociType)
                {
                    buffer.WriteInt32(bufferOffset, num2);
                    bufferOffset += 4;
                    num           = num2 + 4;
                }
                else
                {
                    num = num2;
                }
                buffer.WriteBytes(bufferOffset, buffer2, parameter.Offset, num2);
                return(num);
            }

            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
                if (!(value is OracleLob))
                {
                    throw System.Data.Common.ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }
                handleToBind = ((OracleLob)value).Descriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.BFILE:
                if (!(value is OracleBFile))
                {
                    throw System.Data.Common.ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }
                handleToBind = ((OracleBFile)value).Descriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                if (value is OracleDateTime)
                {
                    OracleDateTime time = (OracleDateTime)value;
                    if (!time.HasTimeInfo)
                    {
                        throw System.Data.Common.ADP.UnsupportedOracleDateTimeBinding(metaType.OracleType);
                    }
                }
                this._dateTimeDescriptor = OracleDateTime.CreateDescriptor(ociType, connection, value);
                handleToBind             = this._dateTimeDescriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                if (value is OracleDateTime)
                {
                    OracleDateTime time2 = (OracleDateTime)value;
                    if (!time2.HasTimeZoneInfo)
                    {
                        throw System.Data.Common.ADP.UnsupportedOracleDateTimeBinding(OracleType.TimestampWithTZ);
                    }
                }
                this._dateTimeDescriptor = OracleDateTime.CreateDescriptor(ociType, connection, value);
                handleToBind             = this._dateTimeDescriptor;
                return(IntPtr.Size);

            case OCI.DATATYPE.INT_INTERVAL_YM:
                return(OracleMonthSpan.MarshalToNative(value, buffer, bufferOffset));

            case OCI.DATATYPE.INT_INTERVAL_DS:
                return(OracleTimeSpan.MarshalToNative(value, buffer, bufferOffset));
            }
            throw System.Data.Common.ADP.TypeNotSupported(ociType);
        }
Esempio n. 18
0
 public static OracleBoolean LessThan(OracleNumber x, OracleNumber y)
 {
     return(x < y);
 }
		public static OracleNumber Log10 (OracleNumber n)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Log10 ((double) n));
		}
		public static OracleNumber Atan2 (OracleNumber y, OracleNumber x)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Atan2 ((double) y, (double) x));
		}
		public static OracleNumber Modulo (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (x.Value % y.Value);
		}
		public static OracleNumber Ceiling (OracleNumber n)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Ceiling ((double) n));
		}
		public static OracleNumber Negate (OracleNumber x)
		{
			if (x.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (-x.Value);
		}
		public static OracleNumber Divide (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (x.Value / y.Value);
		}
		public static OracleNumber Pow (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Pow ((double) x, (double) y));
		}
		public static OracleNumber Exp (OracleNumber p)
		{
			if (p.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Exp ((double) p));
		}
		public static OracleNumber Shift (OracleNumber n, int digits)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (n * (OracleNumber) (Math.Pow (10, digits)));
		}
		public static OracleNumber Floor (OracleNumber n)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Decimal.Floor (n.Value));
		}
		public static OracleNumber Truncate (OracleNumber n, int position)
		{
			throw new NotImplementedException ();
		}
		public static OracleBoolean GreaterThan (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value > y.Value);
		}
		public static OracleNumber Abs (OracleNumber n)
		{
			if (n.IsNull)
				return OracleNumber.Null;
			return new OracleNumber (Math.Abs (n.Value));
		}
		public static OracleBoolean LessThanOrEqual (OracleNumber x, OracleNumber y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value <= y.Value);
		}
        internal object GetOutputValue(NativeBuffer parameterBuffer, OracleConnection connection, bool needCLSType)
        {
            object obj2;
            if (parameterBuffer.ReadInt16(this._indicatorOffset) == -1)
            {
                return DBNull.Value;
            }
            switch (this._bindingMetaType.OciType)
            {
                case OCI.DATATYPE.VARCHAR2:
                case OCI.DATATYPE.LONG:
                case OCI.DATATYPE.LONGVARCHAR:
                case OCI.DATATYPE.CHAR:
                {
                    obj2 = new OracleString(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection, this._bindAsUCS2, true);
                    int size = this._parameter.Size;
                    if (size != 0)
                    {
                        OracleString str4 = (OracleString) obj2;
                        if (size < str4.Length)
                        {
                            OracleString str3 = (OracleString) obj2;
                            string s = str3.Value.Substring(0, size);
                            if (needCLSType)
                            {
                                return s;
                            }
                            return new OracleString(s);
                        }
                    }
                    if (needCLSType)
                    {
                        OracleString str2 = (OracleString) obj2;
                        obj2 = str2.Value;
                    }
                    return obj2;
                }
                case OCI.DATATYPE.INTEGER:
                case OCI.DATATYPE.FLOAT:
                case OCI.DATATYPE.UNSIGNEDINT:
                    return parameterBuffer.PtrToStructure(this._valueOffset, this._bindingMetaType.BaseType);

                case OCI.DATATYPE.VARNUM:
                    obj2 = new OracleNumber(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleNumber number = (OracleNumber) obj2;
                        obj2 = number.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.DATE:
                    obj2 = new OracleDateTime(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection);
                    if (needCLSType)
                    {
                        OracleDateTime time2 = (OracleDateTime) obj2;
                        obj2 = time2.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.RAW:
                case OCI.DATATYPE.LONGRAW:
                case OCI.DATATYPE.LONGVARRAW:
                    obj2 = new OracleBinary(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType);
                    if (needCLSType)
                    {
                        OracleBinary binary = (OracleBinary) obj2;
                        obj2 = binary.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.CLOB:
                case OCI.DATATYPE.BLOB:
                    return new OracleLob(this._locator);

                case OCI.DATATYPE.BFILE:
                    return new OracleBFile(this._locator);

                case OCI.DATATYPE.RSET:
                    return new OracleDataReader(connection, this._descriptor);

                case OCI.DATATYPE.INT_TIMESTAMP:
                case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                    obj2 = new OracleDateTime(this._dateTimeDescriptor, this._bindingMetaType, connection);
                    if (needCLSType)
                    {
                        OracleDateTime time = (OracleDateTime) obj2;
                        obj2 = time.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.INT_INTERVAL_YM:
                    obj2 = new OracleMonthSpan(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleMonthSpan span2 = (OracleMonthSpan) obj2;
                        obj2 = span2.Value;
                    }
                    return obj2;

                case OCI.DATATYPE.INT_INTERVAL_DS:
                    obj2 = new OracleTimeSpan(parameterBuffer, this._valueOffset);
                    if (needCLSType)
                    {
                        OracleTimeSpan span = (OracleTimeSpan) obj2;
                        obj2 = span.Value;
                    }
                    return obj2;
            }
            throw System.Data.Common.ADP.TypeNotSupported(this._bindingMetaType.OciType);
        }
        internal object GetOutputValue(NativeBuffer parameterBuffer, OracleConnection connection, bool needCLSType)
        {
            object obj2;

            if (parameterBuffer.ReadInt16(this._indicatorOffset) == -1)
            {
                return(DBNull.Value);
            }
            switch (this._bindingMetaType.OciType)
            {
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
            case OCI.DATATYPE.CHAR:
            {
                obj2 = new OracleString(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection, this._bindAsUCS2, true);
                int size = this._parameter.Size;
                if (size != 0)
                {
                    OracleString str4 = (OracleString)obj2;
                    if (size < str4.Length)
                    {
                        OracleString str3 = (OracleString)obj2;
                        string       s    = str3.Value.Substring(0, size);
                        if (needCLSType)
                        {
                            return(s);
                        }
                        return(new OracleString(s));
                    }
                }
                if (needCLSType)
                {
                    OracleString str2 = (OracleString)obj2;
                    obj2 = str2.Value;
                }
                return(obj2);
            }

            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.UNSIGNEDINT:
                return(parameterBuffer.PtrToStructure(this._valueOffset, this._bindingMetaType.BaseType));

            case OCI.DATATYPE.VARNUM:
                obj2 = new OracleNumber(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleNumber number = (OracleNumber)obj2;
                    obj2 = number.Value;
                }
                return(obj2);

            case OCI.DATATYPE.DATE:
                obj2 = new OracleDateTime(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType, connection);
                if (needCLSType)
                {
                    OracleDateTime time2 = (OracleDateTime)obj2;
                    obj2 = time2.Value;
                }
                return(obj2);

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
                obj2 = new OracleBinary(parameterBuffer, this._valueOffset, this._lengthOffset, this._bindingMetaType);
                if (needCLSType)
                {
                    OracleBinary binary = (OracleBinary)obj2;
                    obj2 = binary.Value;
                }
                return(obj2);

            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
                return(new OracleLob(this._locator));

            case OCI.DATATYPE.BFILE:
                return(new OracleBFile(this._locator));

            case OCI.DATATYPE.RSET:
                return(new OracleDataReader(connection, this._descriptor));

            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                obj2 = new OracleDateTime(this._dateTimeDescriptor, this._bindingMetaType, connection);
                if (needCLSType)
                {
                    OracleDateTime time = (OracleDateTime)obj2;
                    obj2 = time.Value;
                }
                return(obj2);

            case OCI.DATATYPE.INT_INTERVAL_YM:
                obj2 = new OracleMonthSpan(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleMonthSpan span2 = (OracleMonthSpan)obj2;
                    obj2 = span2.Value;
                }
                return(obj2);

            case OCI.DATATYPE.INT_INTERVAL_DS:
                obj2 = new OracleTimeSpan(parameterBuffer, this._valueOffset);
                if (needCLSType)
                {
                    OracleTimeSpan span = (OracleTimeSpan)obj2;
                    obj2 = span.Value;
                }
                return(obj2);
            }
            throw System.Data.Common.ADP.TypeNotSupported(this._bindingMetaType.OciType);
        }