コード例 #1
0
        public int CompareTo(object obj)
        {
            OracleDateTime o = (OracleDateTime)obj;

            if (obj == null)
            {
                throw new NullReferenceException("Object reference not set to an instance of an object");
            }
            else if (!(obj is OracleDateTime))
            {
                throw new ArgumentException("Value is not a System.Data.OracleClient.OracleDateTime", obj.ToString());
            }
            else if (o.IsNull && this.IsNull)
            {
                return(0);
            }
            else if (o.IsNull && !(this.IsNull))
            {
                return(1);
            }
            else
            {
                return(value.CompareTo(o.Value));
            }
        }
コード例 #2
0
 public static OracleBoolean GreaterThan(OracleDateTime x, OracleDateTime y)
 {
     if (x.IsNull || y.IsNull)
     {
         return(OracleBoolean.Null);
     }
     return(new OracleBoolean(x.Value > y.Value));
 }
コード例 #3
0
 public static OracleBoolean LessThanOrEqual(OracleDateTime x, OracleDateTime y)
 {
     if (x.IsNull || y.IsNull)
     {
         return(OracleBoolean.Null);
     }
     return(new OracleBoolean(x.Value <= y.Value));
 }
コード例 #4
0
 public static OracleBoolean NotEquals(OracleDateTime x, OracleDateTime y)
 {
     if (x.IsNull || y.IsNull)
     {
         return(OracleBoolean.Null);
     }
     return(new OracleBoolean(x.Value != y.Value));
 }
コード例 #5
0
 internal DateTime GetDateTime(NativeBuffer_RowBuffer buffer)
 {
     if (this.IsDBNull(buffer))
     {
         throw System.Data.Common.ADP.DataReaderNoData();
     }
     if (typeof(DateTime) != this._metaType.BaseType)
     {
         throw System.Data.Common.ADP.InvalidCast();
     }
     return(OracleDateTime.MarshalToDateTime(buffer, this._valueOffset, this._lengthOffset, this._metaType, this._connection));
 }
コード例 #6
0
        internal static OciDateTimeDescriptor CreateDescriptor(OCI.DATATYPE ociType, OracleConnection connection, object value)
        {
            byte[]       buffer;
            OCI.DATATYPE tIMESTAMP;
            if (value is OracleDateTime)
            {
                buffer = ((OracleDateTime)value)._value;
            }
            else
            {
                DateTime       dt    = (DateTime)value;
                OracleDateTime time2 = new OracleDateTime(dt);
                buffer = time2._value;
            }
            switch (ociType)
            {
            case OCI.DATATYPE.INT_TIMESTAMP:
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP;
                break;

            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP_LTZ;
                break;

            default:
            {
                tIMESTAMP = OCI.DATATYPE.TIMESTAMP_TZ;
                TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                if (buffer.Length < 13)
                {
                    byte[] dst = new byte[13];
                    Buffer.BlockCopy(buffer, 0, dst, 0, buffer.Length);
                    buffer     = dst;
                    buffer[11] = (byte)(20 + serverTimeZoneAdjustmentToUTC.Hours);
                    buffer[12] = (byte)(60 + serverTimeZoneAdjustmentToUTC.Minutes);
                }
                break;
            }
            }
            OciDateTimeDescriptor datetime = CreateEmptyDescriptor(ociType, connection);
            OciIntervalDescriptor reftz    = new OciIntervalDescriptor(connection.EnvironmentHandle);
            int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, buffer, (uint)buffer.Length, (byte)tIMESTAMP, datetime, reftz, 9);

            if (rc != 0)
            {
                connection.CheckError(connection.ErrorHandle, rc);
            }
            return(datetime);
        }
コード例 #7
0
 public override bool Equals(object value)
 {
     if (value is OracleDateTime)
     {
         OracleDateTime d = (OracleDateTime)value;
         if (!(this.IsNull) && !(d.IsNull))
         {
             return(this.value == d.value);
         }
         else
         {
             throw new InvalidOperationException("The value is null");
         }
     }
     return(false);
 }
コード例 #8
0
 public static OracleBoolean LessThan(OracleDateTime x, OracleDateTime y)
 {
     return (x < y);
 }
コード例 #9
0
 // Alternative method for operator <=
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.LessThanOrEqual"]/*' />
 public static OracleBoolean LessThanOrEqual(OracleDateTime x, OracleDateTime y)
 {
     return(x <= y);
 }
コード例 #10
0
 // Alternative method for operator >=
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.GreaterThanOrEqual"]/*' />
 public static OracleBoolean GreaterThanOrEqual(OracleDateTime x, OracleDateTime y)
 {
     return(x >= y);
 }
コード例 #11
0
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////
        //
        // Methods
        //
        ////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////

        /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.CompareTo"]/*' />
        public int CompareTo(
            object obj
            )
        {
            if (obj.GetType() == typeof(OracleDateTime))
            {
                OracleDateTime odt = (OracleDateTime)obj;

                // If both values are Null, consider them equal.
                // Otherwise, Null is less than anything.
                if (IsNull)
                {
                    return(odt.IsNull ? 0  : -1);
                }

                if (odt.IsNull)
                {
                    return(1);
                }

                // Neither value is null, do the comparison, but take the Timezone into account.

                int year1, month1, day1, hour1, minute1, second1, fsec1;
                int year2, month2, day2, hour2, minute2, second2, fsec2;

                Unpack(_value, out year1, out month1, out day1, out hour1, out minute1, out second1, out fsec1);
                Unpack(odt._value, out year2, out month2, out day2, out hour2, out minute2, out second2, out fsec2);

                int delta;

                delta = (year1 - year2);                if (0 != delta)
                {
                    return(delta);
                }
                delta = (month1 - month2);              if (0 != delta)
                {
                    return(delta);
                }
                delta = (day1 - day2);                  if (0 != delta)
                {
                    return(delta);
                }
                delta = (hour1 - hour2);                if (0 != delta)
                {
                    return(delta);
                }
                delta = (minute1 - minute2);    if (0 != delta)
                {
                    return(delta);
                }
                delta = (second1 - second2);    if (0 != delta)
                {
                    return(delta);
                }
                delta = (fsec1 - fsec2);                if (0 != delta)
                {
                    return(delta);
                }
                return(0);
            }

            // Wrong type!
            throw ADP.Argument();
        }
        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);
        }
コード例 #13
0
        internal object GetOutputValue(
            NativeBuffer parameterBuffer,
            OracleConnection connection,                // connection, so we can create LOB values
            bool needCLSType
            )
        {
            object result;

            //  Returns an object that contains the value of the column in the
            //  specified row buffer.  This method returns Oracle-typed objects.

            if (Marshal.ReadInt16((IntPtr)parameterBuffer.Ptr, _indicatorOffset) == (Int16)OCI.INDICATOR.ISNULL)
            {
                return(DBNull.Value);
            }

            switch (_bindingMetaType.OciType)
            {
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.UNSIGNEDINT:
                result = Marshal.PtrToStructure((IntPtr)parameterBuffer.PtrOffset(_valueOffset), _bindingMetaType.BaseType);
                return(result);

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

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

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

            case OCI.DATATYPE.DATE:
            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                result = new OracleDateTime(parameterBuffer, _valueOffset, _bindingMetaType, connection);
                if (needCLSType)
                {
                    object newresult = ((OracleDateTime)result).Value;
                    result = newresult;
                }
                return(result);

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

            case OCI.DATATYPE.INT_INTERVAL_YM:
                result = new OracleMonthSpan(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleMonthSpan)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.VARNUM:
                result = new OracleNumber(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleNumber)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.CHAR:
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
                result = new OracleString(parameterBuffer,
                                          _valueOffset,
                                          _lengthOffset,
                                          _bindingMetaType,
                                          connection,
                                          _bindAsUCS2,
                                          true
                                          );
                int size = _parameter.Size;
                if (0 != size && size < ((OracleString)result).Length)
                {
                    string truncatedResult = ((OracleString)result).Value.Substring(0, size);
                    if (needCLSType)
                    {
                        result = truncatedResult;
                    }
                    else
                    {
                        result = new OracleString(truncatedResult);
                    }
                }
                else if (needCLSType)
                {
                    object newresult = ((OracleString)result).Value;
                    result = newresult;
                }
                return(result);

            case OCI.DATATYPE.INT_INTERVAL_DS:
                result = new OracleTimeSpan(parameterBuffer, _valueOffset);
                if (needCLSType)
                {
                    object newresult = ((OracleTimeSpan)result).Value;
                    result = newresult;
                }
                return(result);
            }
            throw ADP.TypeNotSupported(_bindingMetaType.OciType);
        }
コード例 #14
0
        internal void Bind(OciStatementHandle statementHandle, NativeBuffer parameterBuffer, OracleConnection connection, ref bool mustRelease, ref SafeHandle handleToBind)
        {
            if (IsDirection(this.Parameter, ParameterDirection.Output) || (this.Parameter.Value != null))
            {
                int                     num2;
                IntPtr                  ptr2;
                string                  parameterName        = this.Parameter.ParameterName;
                OciErrorHandle          errorHandle          = connection.ErrorHandle;
                OciServiceContextHandle serviceContextHandle = connection.ServiceContextHandle;
                int                     num     = 0;
                OCI.INDICATOR           oK      = OCI.INDICATOR.OK;
                OCI.DATATYPE            ociType = this._bindingMetaType.OciType;
                IntPtr                  dataPtr = parameterBuffer.DangerousGetDataPtr(this._indicatorOffset);
                IntPtr                  alenp   = parameterBuffer.DangerousGetDataPtr(this._lengthOffset);
                IntPtr                  valuep  = parameterBuffer.DangerousGetDataPtr(this._valueOffset);
                OciHandle.SafeDispose(ref this._dateTimeDescriptor);
                if (IsDirection(this.Parameter, ParameterDirection.Input))
                {
                    if (System.Data.Common.ADP.IsNull(this._coercedValue))
                    {
                        oK = OCI.INDICATOR.ISNULL;
                        switch (ociType)
                        {
                        case OCI.DATATYPE.INT_TIMESTAMP:
                        case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                        case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                            this._dateTimeDescriptor = OracleDateTime.CreateEmptyDescriptor(ociType, connection);
                            handleToBind             = this._dateTimeDescriptor;
                            break;
                        }
                    }
                    else
                    {
                        num = this.PutOracleValue(this._coercedValue, parameterBuffer, this._valueOffset, this._bindingMetaType, connection, ref handleToBind);
                    }
                }
                else
                {
                    if (this._bindingMetaType.IsVariableLength)
                    {
                        num = 0;
                    }
                    else
                    {
                        num = this._bufferLength;
                    }
                    OciLobLocator.SafeDispose(ref this._locator);
                    OciHandle.SafeDispose(ref this._descriptor);
                    switch (ociType)
                    {
                    case OCI.DATATYPE.CLOB:
                    case OCI.DATATYPE.BLOB:
                    case OCI.DATATYPE.BFILE:
                        this._locator = new OciLobLocator(connection, this._bindingMetaType.OracleType);
                        handleToBind  = this._locator.Descriptor;
                        break;

                    case OCI.DATATYPE.RSET:
                        this._descriptor = new OciStatementHandle(serviceContextHandle);
                        handleToBind     = this._descriptor;
                        break;

                    case OCI.DATATYPE.INT_TIMESTAMP:
                    case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                    case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                        this._dateTimeDescriptor = OracleDateTime.CreateEmptyDescriptor(ociType, connection);
                        handleToBind             = this._dateTimeDescriptor;
                        break;
                    }
                }
                if (handleToBind != null)
                {
                    handleToBind.DangerousAddRef(ref mustRelease);
                    parameterBuffer.WriteIntPtr(this._valueOffset, handleToBind.DangerousGetHandle());
                }
                parameterBuffer.WriteInt16(this._indicatorOffset, (short)oK);
                if ((OCI.DATATYPE.LONGVARCHAR == ociType) || (OCI.DATATYPE.LONGVARRAW == ociType))
                {
                    alenp = IntPtr.Zero;
                }
                else if (this._bindAsUCS2)
                {
                    parameterBuffer.WriteInt32(this._lengthOffset, num / System.Data.Common.ADP.CharSize);
                }
                else
                {
                    parameterBuffer.WriteInt32(this._lengthOffset, num);
                }
                if (IsDirection(this.Parameter, ParameterDirection.Output))
                {
                    num2 = this._bufferLength;
                }
                else
                {
                    num2 = num;
                }
                OCI.DATATYPE dty = ociType;
                switch (ociType)
                {
                case OCI.DATATYPE.INT_TIMESTAMP:
                    dty = OCI.DATATYPE.TIMESTAMP;
                    break;

                case OCI.DATATYPE.INT_TIMESTAMP_TZ:
                    dty = OCI.DATATYPE.TIMESTAMP_TZ;
                    break;

                case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                    dty = OCI.DATATYPE.TIMESTAMP_LTZ;
                    break;
                }
                int rc = TracedNativeMethods.OCIBindByName(statementHandle, out ptr2, errorHandle, parameterName, parameterName.Length, valuep, num2, dty, dataPtr, alenp, OCI.MODE.OCI_DEFAULT);
                if (rc != 0)
                {
                    this._command.Connection.CheckError(errorHandle, rc);
                }
                this._bindHandle = new OciBindHandle(statementHandle, ptr2);
                if (this._bindingMetaType.IsCharacterType)
                {
                    if (OCI.ClientVersionAtLeastOracle9i && IsDirection(this.Parameter, ParameterDirection.Output))
                    {
                        this._bindHandle.SetAttribute(OCI.ATTR.OCI_ATTR_MAXCHAR_SIZE, this._bindSize, errorHandle);
                    }
                    if ((num2 > (this._bindingMetaType.MaxBindSize / System.Data.Common.ADP.CharSize)) || (!OCI.ClientVersionAtLeastOracle9i && this._bindingMetaType.UsesNationalCharacterSet))
                    {
                        this._bindHandle.SetAttribute(OCI.ATTR.OCI_ATTR_MAXDATA_SIZE, this._bindingMetaType.MaxBindSize, errorHandle);
                    }
                    if (this._bindingMetaType.UsesNationalCharacterSet)
                    {
                        this._bindHandle.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, 2, errorHandle);
                    }
                    if (this._bindAsUCS2)
                    {
                        this._bindHandle.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_ID, 0x3e8, errorHandle);
                    }
                }
                GC.KeepAlive(parameterBuffer);
            }
        }
コード例 #15
0
ファイル: OracleDateTime.cs プロジェクト: nlhepler/mono
		public static OracleBoolean LessThanOrEqual (OracleDateTime x, OracleDateTime y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value <= y.Value);
		}
コード例 #16
0
ファイル: OracleDateTime.cs プロジェクト: nlhepler/mono
		public static OracleBoolean GreaterThan (OracleDateTime x, OracleDateTime y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value > y.Value);
		}
コード例 #17
0
 static OracleDateTime()
 {
     MaxValue = new OracleDateTime(DateTime.MaxValue);
     MinValue = new OracleDateTime(DateTime.MinValue);
     Null = new OracleDateTime(true);
 }
コード例 #18
0
 public OracleDateTime(OracleDateTime from)
 {
     this._value = new byte[from._value.Length];
     from._value.CopyTo(this._value, 0);
 }
コード例 #19
0
 public static OracleBoolean NotEquals(OracleDateTime x, OracleDateTime y)
 {
     return (x != y);
 }
コード例 #20
0
 public static OracleBoolean LessThanOrEqual(OracleDateTime x, OracleDateTime y)
 {
     return (x <= y);
 }
コード例 #21
0
        internal static OciDateTimeDescriptor CreateDescriptor(OCI.DATATYPE ociType, OracleConnection connection, object value)
        {
            byte[] buffer;
            OCI.DATATYPE tIMESTAMP;
            if (value is OracleDateTime)
            {
                buffer = ((OracleDateTime) value)._value;
            }
            else
            {
                DateTime dt = (DateTime) value;
                OracleDateTime time2 = new OracleDateTime(dt);
                buffer = time2._value;
            }
            switch (ociType)
            {
                case OCI.DATATYPE.INT_TIMESTAMP:
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP;
                    break;

                case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP_LTZ;
                    break;

                default:
                {
                    tIMESTAMP = OCI.DATATYPE.TIMESTAMP_TZ;
                    TimeSpan serverTimeZoneAdjustmentToUTC = connection.ServerTimeZoneAdjustmentToUTC;
                    if (buffer.Length < 13)
                    {
                        byte[] dst = new byte[13];
                        Buffer.BlockCopy(buffer, 0, dst, 0, buffer.Length);
                        buffer = dst;
                        buffer[11] = (byte) (20 + serverTimeZoneAdjustmentToUTC.Hours);
                        buffer[12] = (byte) (60 + serverTimeZoneAdjustmentToUTC.Minutes);
                    }
                    break;
                }
            }
            OciDateTimeDescriptor datetime = CreateEmptyDescriptor(ociType, connection);
            OciIntervalDescriptor reftz = new OciIntervalDescriptor(connection.EnvironmentHandle);
            int rc = System.Data.Common.UnsafeNativeMethods.OCIDateTimeFromArray(connection.EnvironmentHandle, connection.ErrorHandle, buffer, (uint) buffer.Length, (byte) tIMESTAMP, datetime, reftz, 9);
            if (rc != 0)
            {
                connection.CheckError(connection.ErrorHandle, rc);
            }
            return datetime;
        }
コード例 #22
0
        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);
        }
コード例 #23
0
ファイル: OracleDateTime.cs プロジェクト: nlhepler/mono
		public static OracleBoolean NotEquals (OracleDateTime x, OracleDateTime y)
		{
			if (x.IsNull || y.IsNull)
				return OracleBoolean.Null;
			return new OracleBoolean (x.Value != y.Value);
		}
コード例 #24
0
 public OracleDateTime(OracleDateTime from)
     : this(from.Value)
 {
 }
コード例 #25
0
ファイル: OracleDateTime.cs プロジェクト: nlhepler/mono
		public OracleDateTime (OracleDateTime from)
			: this (from.Value)
		{
		}
コード例 #26
0
        internal int PutOracleValue(
            object value,
            HandleRef valueBuffer,
            MetaType metaType,
            OracleConnection connection
            )
        {
            //  writes the managed object into the buffer in the appropriate
            //  native Oracle format.

            OCI.DATATYPE    ociType = metaType.OciType;
            int             dataSize;
            OracleParameter parameter = Parameter;

            switch (ociType)
            {
            case OCI.DATATYPE.FLOAT:
            case OCI.DATATYPE.INTEGER:
            case OCI.DATATYPE.UNSIGNEDINT:
                Marshal.StructureToPtr(value, (IntPtr)valueBuffer, false);
                dataSize = metaType.BindSize;
                break;

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            case OCI.DATATYPE.LONGVARRAW:
                dataSize = OracleBinary.MarshalToNative(value, parameter.Offset, parameter.Size, valueBuffer, ociType);
                break;

            case OCI.DATATYPE.DATE:
            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                dataSize = OracleDateTime.MarshalToNative(value, valueBuffer, ociType);
                break;

            case OCI.DATATYPE.BFILE:
                // We cannot construct lobs; if you want to bind a lob, you have to have
                // a lob.
                if (!(value is OracleBFile))
                {
                    throw ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }

                Marshal.WriteIntPtr((IntPtr)valueBuffer, (IntPtr)((OracleBFile)value).Descriptor.Handle);
                dataSize = IntPtr.Size;
                break;

            case OCI.DATATYPE.BLOB:
            case OCI.DATATYPE.CLOB:
                // We cannot construct lobs; if you want to bind a lob, you have to have
                // a lob.
                if (!(value is OracleLob))
                {
                    throw ADP.BadBindValueType(value.GetType(), metaType.OracleType);
                }

                // If you don't disable the buffering, you'll cause the PL/SQL code that
                // uses this LOB to have problems doing things like DBMS_LOB.GET_LENGTH()
                ((OracleLob)value).EnsureBuffering(false);

                Marshal.WriteIntPtr((IntPtr)valueBuffer, (IntPtr)((OracleLob)value).Descriptor.Handle);
                dataSize = IntPtr.Size;
                break;

            case OCI.DATATYPE.INT_INTERVAL_YM:
                dataSize = OracleMonthSpan.MarshalToNative(value, valueBuffer);
                break;

            case OCI.DATATYPE.VARNUM:
                dataSize = OracleNumber.MarshalToNative(value, valueBuffer, connection);
                break;

            case OCI.DATATYPE.CHAR:
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.LONGVARCHAR:
                dataSize = OracleString.MarshalToNative(value, parameter.Offset, parameter.Size, valueBuffer, ociType, _bindAsUCS2);
                break;

            case OCI.DATATYPE.INT_INTERVAL_DS:
                dataSize = OracleTimeSpan.MarshalToNative(value, valueBuffer);
                break;

            default:
                throw ADP.TypeNotSupported(ociType);
            }

            Debug.Assert(dataSize <= _bufferLengthInBytes, String.Format("Internal Error: Exceeded Internal Buffer.  DataSize={0} BufferLength={1}", dataSize, _bufferLengthInBytes));
            return(dataSize);
        }
コード例 #27
0
        public int CompareTo(object obj)
        {
            int num2;
            int num3;
            int num4;
            int num5;
            int num6;
            int num7;
            int num8;
            int num9;
            int num10;
            int num11;
            int num12;
            int num13;
            int num14;
            int num15;

            if (!(obj.GetType() == typeof(OracleDateTime)))
            {
                throw System.Data.Common.ADP.WrongType(obj.GetType(), typeof(OracleDateTime));
            }
            OracleDateTime time = (OracleDateTime)obj;

            if (this.IsNull)
            {
                if (!time.IsNull)
                {
                    return(-1);
                }
                return(0);
            }
            if (time.IsNull)
            {
                return(1);
            }
            Unpack(this._value, out num15, out num14, out num13, out num12, out num11, out num10, out num9);
            Unpack(time._value, out num8, out num7, out num6, out num5, out num4, out num3, out num2);
            int num = num15 - num8;

            if (num != 0)
            {
                return(num);
            }
            num = num14 - num7;
            if (num != 0)
            {
                return(num);
            }
            num = num13 - num6;
            if (num != 0)
            {
                return(num);
            }
            num = num12 - num5;
            if (num != 0)
            {
                return(num);
            }
            num = num11 - num4;
            if (num != 0)
            {
                return(num);
            }
            num = num10 - num3;
            if (num != 0)
            {
                return(num);
            }
            num = num9 - num2;
            if (num != 0)
            {
                return(num);
            }
            return(0);
        }
コード例 #28
0
 // Copy constructor
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.OracleDateTime9"]/*' />
 public OracleDateTime(OracleDateTime from)
 {
     _value = new byte[from._value.Length];
     from._value.CopyTo(_value, 0);
 }
コード例 #29
0
        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);
        }
コード例 #30
0
 // Alternative method for operator >
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.GreaterThan"]/*' />
 public static OracleBoolean GreaterThan(OracleDateTime x, OracleDateTime y)
 {
     return(x > y);
 }
コード例 #31
0
 static OracleDateTime()
 {
     MaxValue = new OracleDateTime(DateTime.MaxValue);
     MinValue = new OracleDateTime(DateTime.MinValue);
     Null     = new OracleDateTime(true);
 }
コード例 #32
0
 // Alternative method for operator <
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.LessThan"]/*' />
 public static OracleBoolean LessThan(OracleDateTime x, OracleDateTime y)
 {
     return(x < y);
 }
コード例 #33
0
 public static OracleBoolean GreaterThan(OracleDateTime x, OracleDateTime y)
 {
     return (x > y);
 }
コード例 #34
0
 // Alternative method for operator !=
 /// <include file='doc\OracleDateTime.uex' path='docs/doc[@for="OracleDateTime.NotEquals"]/*' />
 public static OracleBoolean NotEquals(OracleDateTime x, OracleDateTime y)
 {
     return(x != y);
 }
コード例 #35
0
 public static OracleBoolean GreaterThanOrEqual(OracleDateTime x, OracleDateTime y)
 {
     return (x >= y);
 }