예제 #1
0
        internal object GetValue(NativeBuffer_RowBuffer buffer)
        {
            if (this.IsDBNull(buffer))
            {
                return(DBNull.Value);
            }
            switch (this._metaType.OciType)
            {
            case OCI.DATATYPE.VARNUM:
                return(this.GetDecimal(buffer));

            case OCI.DATATYPE.LONG:
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.CHAR:
                return(this.GetString(buffer));

            case OCI.DATATYPE.RAW:
            case OCI.DATATYPE.LONGRAW:
            {
                long   num = this.GetBytes(buffer, 0L, null, 0, 0);
                byte[] destinationBuffer = new byte[num];
                this.GetBytes(buffer, 0L, destinationBuffer, 0, (int)num);
                return(destinationBuffer);
            }

            case OCI.DATATYPE.DATE:
            case OCI.DATATYPE.INT_TIMESTAMP:
            case OCI.DATATYPE.INT_TIMESTAMP_TZ:
            case OCI.DATATYPE.INT_TIMESTAMP_LTZ:
                return(this.GetDateTime(buffer));

            case OCI.DATATYPE.CLOB:
            case OCI.DATATYPE.BLOB:
            {
                using (OracleLob lob = this.GetOracleLob(buffer))
                {
                    return(lob.Value);
                }
            }

            case OCI.DATATYPE.BFILE:
            {
                using (OracleBFile file = this.GetOracleBFile(buffer))
                {
                    return(file.Value);
                }
            }

            case OCI.DATATYPE.INT_INTERVAL_YM:
                return(this.GetInt32(buffer));

            case OCI.DATATYPE.INT_INTERVAL_DS:
                return(this.GetTimeSpan(buffer));
            }
            throw System.Data.Common.ADP.TypeNotSupported(this._metaType.OciType);
        }
        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);
        }
 internal OracleBFile(OracleBFile bfile)
 {
     this._lob = (OracleLob) bfile._lob.Clone();
     this._fileName = bfile._fileName;
     this._directoryAlias = bfile._directoryAlias;
 }
예제 #4
0
        /// <include file='doc\OracleBFile.uex' path='docs/doc[@for="OracleBFile.Clone"]/*' />
        public object Clone()
        {
            OracleBFile clone = new OracleBFile(this);

            return(clone);
        }