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);
        }
        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);
        }