Ejemplo n.º 1
0
        internal void Bind(OciStatementHandle statementHandle, NativeBuffer_RowBuffer buffer, OciErrorHandle errorHandle, int rowBufferLength)
        {
            OciDefineHandle defnp = null;
            int             num3;

            OCI.MODE     mode    = OCI.MODE.OCI_DEFAULT;
            OCI.DATATYPE ociType = this._metaType.OciType;
            this._rowBuffer = buffer;
            if (this._metaType.IsLong)
            {
                mode = OCI.MODE.OCI_DATA_AT_EXEC;
                num3 = 0x7fffffff;
            }
            else
            {
                num3 = this._byteSize;
            }
            IntPtr zero    = IntPtr.Zero;
            IntPtr rlenp   = IntPtr.Zero;
            IntPtr dataPtr = this._rowBuffer.DangerousGetDataPtr(this._valueOffset);

            if (-1 != this._indicatorOffset)
            {
                zero = this._rowBuffer.DangerousGetDataPtr(this._indicatorOffset);
            }
            if ((-1 != this._lengthOffset) && !this._metaType.IsLong)
            {
                rlenp = this._rowBuffer.DangerousGetDataPtr(this._lengthOffset);
            }
            try
            {
                IntPtr ptr3;
                int    rc = TracedNativeMethods.OCIDefineByPos(statementHandle, out ptr3, errorHandle, ((uint)this._ordinal) + 1, dataPtr, num3, ociType, zero, rlenp, IntPtr.Zero, mode);
                if (rc != 0)
                {
                    this._connection.CheckError(errorHandle, rc);
                }
                defnp = new OciDefineHandle(statementHandle, ptr3);
                if (rowBufferLength != 0)
                {
                    uint pvskip  = (uint)rowBufferLength;
                    uint indskip = (-1 != this._indicatorOffset) ? pvskip : 0;
                    uint rlskip  = ((-1 != this._lengthOffset) && !this._metaType.IsLong) ? pvskip : 0;
                    rc = TracedNativeMethods.OCIDefineArrayOfStruct(defnp, errorHandle, pvskip, indskip, rlskip, 0);
                    if (rc != 0)
                    {
                        this._connection.CheckError(errorHandle, rc);
                    }
                }
                if (this._metaType.UsesNationalCharacterSet)
                {
                    defnp.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, 2, errorHandle);
                }
                if (!this._connection.UnicodeEnabled && this._bindAsUTF16)
                {
                    defnp.SetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_ID, 0x3e8, errorHandle);
                }
                if (this._metaType.IsLong)
                {
                    this._rowBuffer.WriteIntPtr(this._valueOffset, IntPtr.Zero);
                    this._callback = new OCI.Callback.OCICallbackDefine(this._callback_GetColumnPiecewise);
                    rc             = TracedNativeMethods.OCIDefineDynamic(defnp, errorHandle, IntPtr.Zero, this._callback);
                    if (rc != 0)
                    {
                        this._connection.CheckError(errorHandle, rc);
                    }
                }
            }
            finally
            {
                NativeBuffer.SafeDispose(ref this._longBuffer);
                OciHandle.SafeDispose(ref defnp);
            }
        }
        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);
            }
        }
 internal OciServiceContextHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SVCCTX, OCI.MODE.OCI_DEFAULT, OciHandle.HANDLEFLAG.DEFAULT)
 {
 }
Ejemplo n.º 4
0
 internal OciErrorHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_ERROR)
 {
 }
 internal OciDateTimeDescriptor(OciHandle parent, OCI.HTYPE dateTimeType) : base(parent, AssertDateTimeType(dateTimeType))
 {
 }
Ejemplo n.º 6
0
 internal static int DetermineClientVersion()
 {
     if (_clientVersion == 0)
     {
         int  num             = 0;
         MODE environmentMode = MODE.OCI_DATA_AT_EXEC | MODE.OCI_BATCH_MODE;
         try
         {
             System.Data.Common.UnsafeNativeMethods.OCILobCopy2(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, 0L, 0L, 0L);
             num = 0x65;
         }
         catch (EntryPointNotFoundException exception6)
         {
             System.Data.Common.ADP.TraceException(exception6);
             try
             {
                 OciHandle handle = new OciNlsEnvironmentHandle(environmentMode);
                 if (!handle.IsInvalid)
                 {
                     num = 0x5c;
                     OciHandle.SafeDispose(ref handle);
                 }
             }
             catch (EntryPointNotFoundException exception5)
             {
                 System.Data.Common.ADP.TraceException(exception5);
                 try
                 {
                     environmentMode |= MODE.OCI_UTF16;
                     OciHandle handle2 = new OciEnvironmentHandle(environmentMode, true);
                     num = 90;
                     OciHandle.SafeDispose(ref handle2);
                 }
                 catch (EntryPointNotFoundException exception4)
                 {
                     System.Data.Common.ADP.TraceException(exception4);
                     num = 80;
                 }
                 catch (Exception exception)
                 {
                     if (!System.Data.Common.ADP.IsCatchableExceptionType(exception))
                     {
                         throw;
                     }
                     System.Data.Common.ADP.TraceException(exception);
                     num = 0x51;
                 }
             }
         }
         catch (DllNotFoundException exception3)
         {
             System.Data.Common.ADP.TraceException(exception3);
             num = 0x49;
         }
         catch (BadImageFormatException exception2)
         {
             throw System.Data.Common.ADP.BadOracleClientImageFormat(exception2);
         }
         if (0x51 > num)
         {
             throw System.Data.Common.ADP.BadOracleClientVersion();
         }
         _clientVersion = num;
     }
     return(_clientVersion);
 }
Ejemplo n.º 7
0
 internal OciSessionHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SESSION)
 {
 }
Ejemplo n.º 8
0
 static internal Exception OracleError(OciHandle errorHandle, int rc, NativeBuffer scratchpad)
 {
     return(TraceException(new OracleException(errorHandle, rc, scratchpad)));
 }
Ejemplo n.º 9
0
 internal OciServiceContextHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SVCCTX)
 {
 }
Ejemplo n.º 10
0
 internal OciServiceContextHandle(OciHandle parent, IntPtr value, bool transacted) : base(parent, OCI.HTYPE.OCI_HTYPE_SVCCTX, value)
 {
     base._transacted = transacted;
 }
Ejemplo n.º 11
0
 internal OciServerHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SERVER)
 {
 }
Ejemplo n.º 12
0
 internal OciDefineHandle(OciHandle parent, IntPtr value) : base(parent, OCI.HTYPE.OCI_HTYPE_DEFINE, value)
 {
 }
Ejemplo n.º 13
0
        private void Dispose(bool disposing)
        {
            HandleRef localHandle       = Handle;
            OciHandle localParentHandle = _parentOciHandle;

            try
            {
                try
                {
                    _parentOciHandle = null;
                    _handle          = IntPtr.Zero;
                }
                finally
                {
                    // BIND, DEFINE and PARAM handles cannot be freed; they go away automatically
                    // (but you'll have to ask Oracle how...)
                    if (OCI.HTYPE.OCI_HTYPE_BIND != _handleType &&
                        OCI.HTYPE.OCI_HTYPE_DEFINE != _handleType &&
                        OCI.HTYPE.OCI_DTYPE_PARAM != _handleType &&
                        IntPtr.Zero != localHandle.Handle &&
                        !_transacted)
                    {
                        if (_handleType == OCI.HTYPE.OCI_HTYPE_ENV || (null != localParentHandle && localParentHandle.IsAlive))
                        {
                            // DEVNOTE: the finalizer creates a race condition: it is possible
                            //          for both this handle and it's parent to be finalized
                            //          concurrently.  If the parent handle is freed before we
                            //          free this handle, Oracle will AV when we actually get
                            //          to free it.  We put a try/catch around this to avoid
                            //          the unhandled AV in the race condition, but we can't do
                            //          much about cdb, which always breaks on the AV because
                            //          it thinks its an unhandled exception, even though it's
                            //          being handled in managed code.
                            try
                            {
                                if (ExtraDispose(localHandle, _handleType))
                                {
                                    if (_handleType < OCI.HTYPE.OCI_DTYPE_FIRST)
                                    {
                                        TracedNativeMethods.OCIHandleFree(localHandle, _handleType);
                                    }
                                    else
                                    {
                                        TracedNativeMethods.OCIDescriptorFree(localHandle, _handleType);
                                    }
                                }
                            }
                            catch (NullReferenceException e)
                            {
                                ADP.TraceException(e);
                            }
                        }
                    }
                }
            }
            catch // Prevent exception filters from running in our space
            {
                throw;
            }
            GC.KeepAlive(this);
        }
        private bool OpenOnLocalTransaction(string userName, string password, string serverName, bool integratedSecurity, bool unicode, bool omitOracleConnectionName)
        {
            int rc = 0;

            OCI.MODE environmentMode = OCI.MODE.OCI_DATA_AT_EXEC | OCI.MODE.OCI_BATCH_MODE;
            OCI.DetermineClientVersion();
            if (unicode)
            {
                if (OCI.ClientVersionAtLeastOracle9i)
                {
                    environmentMode |= OCI.MODE.OCI_UTF16;
                }
                else
                {
                    unicode = false;
                }
            }
            this._environmentHandle = new OciEnvironmentHandle(environmentMode, unicode);
            if (this._environmentHandle.IsInvalid)
            {
                throw System.Data.Common.ADP.CouldNotCreateEnvironment("OCIEnvCreate", rc);
            }
            this._errorHandle          = new OciErrorHandle(this._environmentHandle);
            this._serverHandle         = new OciServerHandle(this._errorHandle);
            this._sessionHandle        = new OciSessionHandle(this._serverHandle);
            this._serviceContextHandle = new OciServiceContextHandle(this._sessionHandle);
            try
            {
                OCI.CRED cred;
                rc = TracedNativeMethods.OCIServerAttach(this._serverHandle, this._errorHandle, serverName, serverName.Length, OCI.MODE.OCI_DEFAULT);
                if (rc != 0)
                {
                    if (1 == rc)
                    {
                        this.CreateDeferredInfoMessage(this.ErrorHandle, rc);
                    }
                    else
                    {
                        OracleException.Check(this.ErrorHandle, rc);
                    }
                }
                this._serviceContextHandle.SetAttribute(OCI.ATTR.OCI_ATTR_SERVER, this._serverHandle, this._errorHandle);
                if (integratedSecurity)
                {
                    cred = OCI.CRED.OCI_CRED_EXT;
                }
                else
                {
                    cred = OCI.CRED.OCI_CRED_RDBMS;
                    this._sessionHandle.SetAttribute(OCI.ATTR.OCI_ATTR_USERNAME, userName, this._errorHandle);
                    if (password != null)
                    {
                        this._sessionHandle.SetAttribute(OCI.ATTR.OCI_ATTR_PASSWORD, password, this._errorHandle);
                    }
                }
                if (!omitOracleConnectionName)
                {
                    string dataSource = this._connectionOptions.DataSource;
                    if (dataSource.Length > 0x10)
                    {
                        dataSource = dataSource.Substring(0, 0x10);
                    }
                    this._serverHandle.SetAttribute(OCI.ATTR.OCI_ATTR_EXTERNAL_NAME, dataSource, this._errorHandle);
                    this._serverHandle.SetAttribute(OCI.ATTR.OCI_ATTR_INTERNAL_NAME, dataSource, this._errorHandle);
                }
                rc = TracedNativeMethods.OCISessionBegin(this._serviceContextHandle, this._errorHandle, this._sessionHandle, cred, OCI.MODE.OCI_DEFAULT);
                if (rc != 0)
                {
                    if (1 == rc)
                    {
                        this.CreateDeferredInfoMessage(this.ErrorHandle, rc);
                    }
                    else
                    {
                        OracleException.Check(this.ErrorHandle, rc);
                    }
                }
                this._serviceContextHandle.SetAttribute(OCI.ATTR.OCI_ATTR_SESSION, this._sessionHandle, this._errorHandle);
            }
            catch (OracleException)
            {
                OciHandle.SafeDispose(ref this._serviceContextHandle);
                OciHandle.SafeDispose(ref this._sessionHandle);
                OciHandle.SafeDispose(ref this._serverHandle);
                OciHandle.SafeDispose(ref this._errorHandle);
                OciHandle.SafeDispose(ref this._environmentHandle);
                throw;
            }
            return(true);
        }
Ejemplo n.º 15
0
 internal OciStatementHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_STMT)
 {
 }
Ejemplo n.º 16
0
        override protected DBSqlParserColumnCollection GatherTableColumns(
            DBSqlParserTable table
            )
        {
            //  Called to get a column list for the table specified.

            OciHandle     statementHandle = _connection.EnvironmentHandle.CreateOciHandle(OCI.HTYPE.OCI_HTYPE_STMT);
            OciHandle     errorHandle     = _connection.ErrorHandle;
            StringBuilder sb         = new StringBuilder();
            string        schemaName = table.SchemaName;
            string        tableName  = table.TableName;
            string        columnName;
            int           tableColumnCount;
            int           rc;
            string        tempStatement;

            DBSqlParserColumnCollection columns = new DBSqlParserColumnCollection();

            Debug.Assert(string.Empty == table.DatabaseName, "oracle doesn't support 4 part names!");

            sb.Append("select * from ");

            if (String.Empty != schemaName)
            {
                sb.Append(schemaName);
                sb.Append(".");
            }

            sb.Append(tableName);

            tempStatement = sb.ToString();

            rc = TracedNativeMethods.OCIStmtPrepare(
                statementHandle,
                errorHandle,
                tempStatement,
                tempStatement.Length,
                OCI.SYNTAX.OCI_NTV_SYNTAX,
                OCI.MODE.OCI_DEFAULT,
                _connection
                );

            if (0 == rc)
            {
                rc = TracedNativeMethods.OCIStmtExecute(
                    _connection.ServiceContextHandle,
                    statementHandle,
                    errorHandle,
                    0,                                              // iters
                    0,                                              // rowoff
                    ADP.NullHandleRef,                              // snap_in
                    ADP.NullHandleRef,                              // snap_out
                    OCI.MODE.OCI_DESCRIBE_ONLY                      // mode
                    );

                if (0 == rc)
                {
                    // Build the column list for the table
                    statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_PARAM_COUNT, out tableColumnCount, errorHandle);

                    for (int j = 0; j < tableColumnCount; j++)
                    {
                        OciHandle describeHandle = statementHandle.GetDescriptor(j, errorHandle);
                        describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_NAME, out columnName, errorHandle, _connection);
                        OciHandle.SafeDispose(ref describeHandle);

                        columnName = QuotePrefixCharacter + columnName + QuoteSuffixCharacter;

                        columns.Add(null, schemaName, tableName, columnName, null);
                    }

                    // Now, derive the key information for the statement and update the column list
                    // with it.
                }
            }

            // Clean up and return;
            OciHandle.SafeDispose(ref statementHandle);

            return(columns);
        }
Ejemplo n.º 17
0
 internal OciLobDescriptor(OciHandle parent) : base(parent, OCI.HTYPE.OCI_DTYPE_LOB)
 {
 }
        internal static OracleString GetPersistedRowid(OracleConnection connection, OciRowidDescriptor rowidHandle)
        {
            OracleString @null = OracleString.Null;

            if (rowidHandle != null)
            {
                OciErrorHandle errorHandle   = connection.ErrorHandle;
                NativeBuffer   scratchBuffer = connection.GetScratchBuffer(0xf82);
                bool           success       = false;
                bool           flag          = false;
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    int num;
                    scratchBuffer.DangerousAddRef(ref success);
                    if (OCI.ClientVersionAtLeastOracle9i)
                    {
                        int length = scratchBuffer.Length;
                        num = TracedNativeMethods.OCIRowidToChar(rowidHandle, scratchBuffer, ref length, errorHandle);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        return(new OracleString(scratchBuffer.PtrToStringAnsi(0, length)));
                    }
                    rowidHandle.DangerousAddRef(ref flag);
                    OciServiceContextHandle serviceContextHandle = connection.ServiceContextHandle;
                    OciStatementHandle      stmtp = new OciStatementHandle(serviceContextHandle);
                    string stmt   = "begin :rowid := :rdesc; end;";
                    int    offset = 0;
                    int    num6   = 4;
                    int    num5   = 8;
                    int    num3   = 12;
                    int    num2   = 0x10;
                    int    num4   = 20;
                    try
                    {
                        IntPtr ptr;
                        IntPtr ptr2;
                        num = TracedNativeMethods.OCIStmtPrepare(stmtp, errorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, connection);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        scratchBuffer.WriteIntPtr(num5, rowidHandle.DangerousGetHandle());
                        scratchBuffer.WriteInt32(offset, 0);
                        scratchBuffer.WriteInt32(num6, 4);
                        scratchBuffer.WriteInt32(num3, 0);
                        scratchBuffer.WriteInt32(num2, 0xf6e);
                        num = TracedNativeMethods.OCIBindByName(stmtp, out ptr2, errorHandle, "rowid", 5, scratchBuffer.DangerousGetDataPtr(num4), 0xf6e, OCI.DATATYPE.VARCHAR2, scratchBuffer.DangerousGetDataPtr(num3), scratchBuffer.DangerousGetDataPtr(num2), OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        num = TracedNativeMethods.OCIBindByName(stmtp, out ptr, errorHandle, "rdesc", 5, scratchBuffer.DangerousGetDataPtr(num5), 4, OCI.DATATYPE.ROWID_DESC, scratchBuffer.DangerousGetDataPtr(offset), scratchBuffer.DangerousGetDataPtr(num6), OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        num = TracedNativeMethods.OCIStmtExecute(serviceContextHandle, stmtp, errorHandle, 1, OCI.MODE.OCI_DEFAULT);
                        if (num != 0)
                        {
                            connection.CheckError(errorHandle, num);
                        }
                        if (scratchBuffer.ReadInt16(num3) == -1)
                        {
                            return(@null);
                        }
                        @null = new OracleString(scratchBuffer, num4, num2, MetaType.GetMetaTypeForType(OracleType.RowId), connection, false, true);
                        GC.KeepAlive(rowidHandle);
                    }
                    finally
                    {
                        OciHandle.SafeDispose(ref stmtp);
                    }
                }
                finally
                {
                    if (flag)
                    {
                        rowidHandle.DangerousRelease();
                    }
                    if (success)
                    {
                        scratchBuffer.DangerousRelease();
                    }
                }
            }
            return(@null);
        }
Ejemplo n.º 19
0
 internal OciRowidDescriptor(OciHandle parent) : base(parent, OCI.HTYPE.OCI_DTYPE_ROWID)
 {
 }
 internal OciFileDescriptor(OciHandle parent) : base(parent, OCI.HTYPE.OCI_DTYPE_FILE)
 {
 }
Ejemplo n.º 21
0
 internal OciServerHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SERVER, OCI.MODE.OCI_DEFAULT, OciHandle.HANDLEFLAG.DEFAULT)
 {
 }
Ejemplo n.º 22
0
 internal OciBindHandle(OciHandle parent, IntPtr value) : base(parent, OCI.HTYPE.OCI_HTYPE_BIND, value)
 {
 }
 internal OciParameterDescriptor(OciHandle parent, IntPtr value) : base(parent, OCI.HTYPE.OCI_DTYPE_PARAM, value)
 {
 }
 internal OciSessionHandle(OciHandle parent) : base(parent, OCI.HTYPE.OCI_HTYPE_SESSION, OCI.MODE.OCI_DEFAULT, OciHandle.HANDLEFLAG.DEFAULT)
 {
 }
 internal OciSimpleHandle(OciHandle parent, OCI.HTYPE handleType, IntPtr value) : base(handleType)
 {
     base.handle = value;
 }
Ejemplo n.º 26
0
        internal OracleException(
            OciHandle errorHandle,
            int rc,
            NativeBuffer buf)
        {
            if (null == buf)
            {
                buf = new NativeBuffer_Exception(1000);
            }
            else if (buf.Length < 1000)
            {
                buf.Length = 1000;
            }


            if (null != errorHandle)
            {
                int record = 1;
                int rcTemp = TracedNativeMethods.OCIErrorGet(
                    errorHandle,
                    record,
                    ADP.NullHandleRef,
                    out code,
                    buf.Ptr,
                    buf.Length
                    );

                if (0 == rcTemp)
                {
                    message = errorHandle.PtrToString((IntPtr)buf.Ptr);

                    // For warning messages, revert back to the OCI7 routine to get
                    // the text of the message.
                    if (code != 0 && message.StartsWith("ORA-00000"))
                    {
                        message = TracedNativeMethods.oermsg(errorHandle, (short)code, buf);
                    }
                }
                else
                {
                    Debug.Assert(false, "Failed to get oracle message text");

                    // If we couldn't successfully read the message text, we pick
                    // something more descriptive, like "we couldn't read the message"
                    // instead of just handing back an empty string...
                    message = Res.GetString(Res.ADP_NoMessageAvailable, rc, rcTemp);
                    code    = 0;
                }
            }
#if USEORAMTS
            else
            {
                int length = buf.Length;
                code = 0;

                int rcTemp = TracedNativeMethods.OraMTSOCIErrGet(ref code, buf.Ptr, ref length);

                if (1 == rcTemp)
                {
                    message = Marshal.PtrToStringAnsi((IntPtr)buf.Ptr);
                }
                else
                {
                    Debug.Assert(false, "Failed to get oracle message text");

                    // If we couldn't successfully read the message text, we pick
                    // something more descriptive, like "we couldn't read the message"
                    // instead of just handing back an empty string...
                    message = Res.GetString(Res.ADP_NoMessageAvailable, rc, rcTemp);
                    code    = 0;
                }
            }
#endif //USEORAMTS
        }
Ejemplo n.º 27
0
        internal bool Describe(ref int offset, OracleConnection connection, OciErrorHandle errorHandle)
        {
            byte  num;
            short num3;
            bool  flag  = false;
            bool  flag2 = false;

            this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SQLCODE, out this._columnName, errorHandle, this._connection);
            this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_OBJECT, out num3, errorHandle);
            this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SESSION, out num, errorHandle);
            this._isNullable = 0 != num;
            OCI.DATATYPE ociType = (OCI.DATATYPE)num3;
            switch (ociType)
            {
            case OCI.DATATYPE.VARCHAR2:
            case OCI.DATATYPE.CHAR:
            {
                int num2;
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_FNCODE, out this._byteSize, errorHandle);
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, out num, errorHandle);
                OCI.CHARSETFORM charsetform = (OCI.CHARSETFORM)num;
                this._bindAsUTF16 = connection.ServerVersionAtLeastOracle8;
                if (connection.ServerVersionAtLeastOracle9i && OCI.ClientVersionAtLeastOracle9i)
                {
                    this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHAR_SIZE, out num3, errorHandle);
                    num2 = num3;
                }
                else
                {
                    num2 = this._byteSize;
                }
                if (charsetform == OCI.CHARSETFORM.SQLCS_NCHAR)
                {
                    this._metaType = MetaType.GetMetaTypeForType((OCI.DATATYPE.CHAR == ociType) ? System.Data.OracleClient.OracleType.NChar : System.Data.OracleClient.OracleType.NVarChar);
                }
                else
                {
                    this._metaType = MetaType.GetMetaTypeForType((OCI.DATATYPE.CHAR == ociType) ? System.Data.OracleClient.OracleType.Char : System.Data.OracleClient.OracleType.VarChar);
                    if (this._bindAsUTF16)
                    {
                        this._byteSize *= System.Data.Common.ADP.CharSize;
                    }
                }
                this._byteSize = Math.Max(this._byteSize, num2 * System.Data.Common.ADP.CharSize);
                flag           = true;
                break;
            }

            case OCI.DATATYPE.NUMBER:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Number);
                this._byteSize = this._metaType.BindSize;
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ENV, out this._precision, errorHandle);
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_SERVER, out this._scale, errorHandle);
                break;

            case OCI.DATATYPE.LONG:
                this._metaType    = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.LongVarChar);
                this._byteSize    = this._metaType.BindSize;
                flag              = true;
                flag2             = true;
                this._bindAsUTF16 = connection.ServerVersionAtLeastOracle8;
                break;

            case OCI.DATATYPE.ROWID:
            case OCI.DATATYPE.ROWID_DESC:
            case OCI.DATATYPE.UROWID:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.RowId);
                this._byteSize = this._metaType.BindSize;
                if (connection.UnicodeEnabled)
                {
                    this._bindAsUTF16 = true;
                    this._byteSize   *= System.Data.Common.ADP.CharSize;
                }
                flag = true;
                break;

            case OCI.DATATYPE.DATE:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.DateTime);
                this._byteSize = this._metaType.BindSize;
                flag           = true;
                break;

            case OCI.DATATYPE.RAW:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Raw);
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_FNCODE, out this._byteSize, errorHandle);
                flag = true;
                break;

            case OCI.DATATYPE.LONGRAW:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.LongRaw);
                this._byteSize = this._metaType.BindSize;
                flag           = true;
                flag2          = true;
                break;

            case OCI.DATATYPE.CLOB:
                this._describeHandle.GetAttribute(OCI.ATTR.OCI_ATTR_CHARSET_FORM, out num, errorHandle);
                this._metaType = MetaType.GetMetaTypeForType((2 == num) ? System.Data.OracleClient.OracleType.NClob : System.Data.OracleClient.OracleType.Clob);
                this._byteSize = this._metaType.BindSize;
                flag2          = true;
                break;

            case OCI.DATATYPE.BLOB:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Blob);
                this._byteSize = this._metaType.BindSize;
                flag2          = true;
                break;

            case OCI.DATATYPE.BFILE:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.BFile);
                this._byteSize = this._metaType.BindSize;
                flag2          = true;
                break;

            case OCI.DATATYPE.TIMESTAMP:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.Timestamp);
                this._byteSize = this._metaType.BindSize;
                flag           = true;
                break;

            case OCI.DATATYPE.TIMESTAMP_TZ:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.TimestampWithTZ);
                this._byteSize = this._metaType.BindSize;
                flag           = true;
                break;

            case OCI.DATATYPE.INTERVAL_YM:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.IntervalYearToMonth);
                this._byteSize = this._metaType.BindSize;
                break;

            case OCI.DATATYPE.INTERVAL_DS:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.IntervalDayToSecond);
                this._byteSize = this._metaType.BindSize;
                break;

            case OCI.DATATYPE.TIMESTAMP_LTZ:
                this._metaType = MetaType.GetMetaTypeForType(System.Data.OracleClient.OracleType.TimestampLocal);
                this._byteSize = this._metaType.BindSize;
                flag           = true;
                break;

            default:
                throw System.Data.Common.ADP.TypeNotSupported(ociType);
            }
            if (this._isNullable)
            {
                this._indicatorOffset = offset;
                offset += IntPtr.Size;
            }
            else
            {
                this._indicatorOffset = -1;
            }
            if (flag)
            {
                this._lengthOffset = offset;
                offset            += IntPtr.Size;
            }
            else
            {
                this._lengthOffset = -1;
            }
            this._valueOffset = offset;
            if ((OCI.DATATYPE.LONG == ociType) || (OCI.DATATYPE.LONGRAW == ociType))
            {
                offset += IntPtr.Size;
            }
            else
            {
                offset += this._byteSize;
            }
            offset = (offset + (IntPtr.Size - 1)) & ~(IntPtr.Size - 1);
            OciHandle.SafeDispose(ref this._describeHandle);
            return(flag2);
        }