Ejemplo n.º 1
0
        internal OciRowidDescriptor GetRowid(OciHandle environmentHandle, OciErrorHandle errorHandle)
        {
            OciRowidDescriptor descriptor = new OciRowidDescriptor(environmentHandle);

            descriptor.GetRowid(this, errorHandle);
            return(descriptor);
        }
 internal static void SafeDispose(ref OciRowidDescriptor handle)
 {
     if (handle != null)
     {
         handle.Dispose();
     }
     handle = null;
 }
        private int ExecuteNonQueryInternal(bool needRowid, out OciRowidDescriptor rowidDescriptor)
        {
            OciStatementHandle statementHandle = null;
            int num = -1;

            try
            {
                try
                {
                    ArrayList resultParameterOrdinals = new ArrayList();
                    statementHandle = this.GetStatementHandle();
                    this.Execute(statementHandle, CommandBehavior.Default, needRowid, out rowidDescriptor, out resultParameterOrdinals);
                    if (resultParameterOrdinals != null)
                    {
                        num = 0;
                        foreach (int num2 in resultParameterOrdinals)
                        {
                            OracleParameter parameter = this._parameterCollection[num2];
                            if (OracleType.Cursor != parameter.OracleType)
                            {
                                num += (int)parameter.Value;
                            }
                        }
                        return(num);
                    }
                    if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
                    {
                        statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ROW_COUNT, out num, this.ErrorHandle);
                    }
                    return(num);
                }
                finally
                {
                    if (statementHandle != null)
                    {
                        this.ReleaseStatementHandle(statementHandle);
                    }
                }
            }
            catch
            {
                throw;
            }
            return(num);
        }
        public object ExecuteOracleScalar()
        {
            object obj2;
            IntPtr ptr;

            OracleConnection.ExecutePermission.Demand();
            Bid.ScopeEnter(out ptr, "<ora.OracleCommand.ExecuteOracleScalar|API> %d#", this.ObjectID);
            try
            {
                OciRowidDescriptor rowidDescriptor = null;
                object             obj3            = this.ExecuteScalarInternal(false, false, out rowidDescriptor);
                OciHandle.SafeDispose(ref rowidDescriptor);
                obj2 = obj3;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(obj2);
        }
        public override int ExecuteNonQuery()
        {
            int    num;
            IntPtr ptr;

            OracleConnection.ExecutePermission.Demand();
            Bid.ScopeEnter(out ptr, "<ora.OracleCommand.ExecuteNonQuery|API> %d#\n", this.ObjectID);
            try
            {
                OciRowidDescriptor rowidDescriptor = null;
                int num2 = this.ExecuteNonQueryInternal(false, out rowidDescriptor);
                OciHandle.SafeDispose(ref rowidDescriptor);
                num = num2;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(num);
        }
        public int ExecuteOracleNonQuery(out OracleString rowid)
        {
            int    num;
            IntPtr ptr;

            OracleConnection.ExecutePermission.Demand();
            Bid.ScopeEnter(out ptr, "<ora.OracleCommand.ExecuteOracleNonQuery|API> %d#\n", this.ObjectID);
            try
            {
                OciRowidDescriptor rowidDescriptor = null;
                int num2 = this.ExecuteNonQueryInternal(true, out rowidDescriptor);
                rowid = GetPersistedRowid(this.Connection, rowidDescriptor);
                OciHandle.SafeDispose(ref rowidDescriptor);
                num = num2;
            }
            finally
            {
                Bid.ScopeLeave(ref ptr);
            }
            return(num);
        }
Ejemplo n.º 7
0
        internal OciHandle GetRowid(
            OciHandle environmentHandle,
            OciHandle errorHandle
            )
        {
            OciHandle rowidHandle = new OciRowidDescriptor(environmentHandle);

            int zero = 0;
            int rc   = TracedNativeMethods.OCIAttrGet(this, rowidHandle, out zero, OCI.ATTR.OCI_ATTR_ROWID, errorHandle);

            if ((int)OCI.RETURNCODE.OCI_NO_DATA == rc)
            {
                SafeDispose(ref rowidHandle);
            }
            else if (0 != rc)
            {
                OracleException.Check(errorHandle, rc);
            }

            GC.KeepAlive(this);
            return(rowidHandle);
        }
 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;
 }
 private object ExecuteScalarInternal(bool needCLStype, bool needRowid, out OciRowidDescriptor rowidDescriptor)
 {
     OciStatementHandle statementHandle = null;
     object oracleValue = null;
     int rc = 0;
     try
     {
         statementHandle = this.GetStatementHandle();
         ArrayList resultParameterOrdinals = new ArrayList();
         this.Execute(statementHandle, CommandBehavior.Default, needRowid, out rowidDescriptor, out resultParameterOrdinals);
         if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
         {
             return oracleValue;
         }
         OracleColumn column = new OracleColumn(statementHandle, 0, this.ErrorHandle, this._connection);
         int offset = 0;
         bool success = false;
         bool mustRelease = false;
         SafeHandle handleToBind = null;
         column.Describe(ref offset, this._connection, this.ErrorHandle);
         NativeBuffer_RowBuffer buffer = new NativeBuffer_RowBuffer(offset, 1);
         RuntimeHelpers.PrepareConstrainedRegions();
         try
         {
             buffer.DangerousAddRef(ref success);
             column.Bind(statementHandle, buffer, this.ErrorHandle, 0);
             column.Rebind(this._connection, ref mustRelease, ref handleToBind);
             rc = TracedNativeMethods.OCIStmtFetch(statementHandle, this.ErrorHandle, 1, OCI.FETCH.OCI_FETCH_NEXT, OCI.MODE.OCI_DEFAULT);
             if (100 != rc)
             {
                 if (rc != 0)
                 {
                     this.Connection.CheckError(this.ErrorHandle, rc);
                 }
                 if (needCLStype)
                 {
                     oracleValue = column.GetValue(buffer);
                 }
                 else
                 {
                     oracleValue = column.GetOracleValue(buffer);
                 }
             }
         }
         finally
         {
             if (mustRelease)
             {
                 handleToBind.DangerousRelease();
             }
             if (success)
             {
                 buffer.DangerousRelease();
             }
         }
         GC.KeepAlive(column);
     }
     finally
     {
         if (statementHandle != null)
         {
             this.ReleaseStatementHandle(statementHandle);
         }
     }
     return oracleValue;
 }
 private int ExecuteNonQueryInternal(bool needRowid, out OciRowidDescriptor rowidDescriptor)
 {
     OciStatementHandle statementHandle = null;
     int num = -1;
     try
     {
         try
         {
             ArrayList resultParameterOrdinals = new ArrayList();
             statementHandle = this.GetStatementHandle();
             this.Execute(statementHandle, CommandBehavior.Default, needRowid, out rowidDescriptor, out resultParameterOrdinals);
             if (resultParameterOrdinals != null)
             {
                 num = 0;
                 foreach (int num2 in resultParameterOrdinals)
                 {
                     OracleParameter parameter = this._parameterCollection[num2];
                     if (OracleType.Cursor != parameter.OracleType)
                     {
                         num += (int) parameter.Value;
                     }
                 }
                 return num;
             }
             if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
             {
                 statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ROW_COUNT, out num, this.ErrorHandle);
             }
             return num;
         }
         finally
         {
             if (statementHandle != null)
             {
                 this.ReleaseStatementHandle(statementHandle);
             }
         }
     }
     catch
     {
         throw;
     }
     return num;
 }
 internal string Execute(OciStatementHandle statementHandle, CommandBehavior behavior, bool needRowid, out OciRowidDescriptor rowidDescriptor, out ArrayList resultParameterOrdinals)
 {
     if (this.ConnectionIsClosed)
     {
         throw System.Data.Common.ADP.ClosedConnectionError();
     }
     if ((this._transaction == null) && (this.Connection.Transaction != null))
     {
         throw System.Data.Common.ADP.TransactionRequired();
     }
     if (((this._transaction != null) && (this._transaction.Connection != null)) && (this.Connection != this._transaction.Connection))
     {
         throw System.Data.Common.ADP.TransactionConnectionMismatch();
     }
     rowidDescriptor = null;
     this.Connection.RollbackDeadTransaction();
     int rc = 0;
     NativeBuffer parameterBuffer = null;
     bool success = false;
     bool[] flagArray = null;
     SafeHandle[] handleArray = null;
     OracleParameterBinding[] bindingArray = null;
     string stmt = null;
     resultParameterOrdinals = null;
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         int num8;
         short num13;
         if (this._preparedStatementHandle != statementHandle)
         {
             stmt = this.StatementText;
             rc = TracedNativeMethods.OCIStmtPrepare(statementHandle, this.ErrorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, this.Connection);
             if (rc != 0)
             {
                 this.Connection.CheckError(this.ErrorHandle, rc);
             }
         }
         statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_STMT_TYPE, out num13, this.ErrorHandle);
         this._statementType = (OCI.STMT) num13;
         if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
         {
             num8 = 1;
         }
         else
         {
             num8 = 0;
             if (CommandBehavior.SingleRow != behavior)
             {
                 statementHandle.SetAttribute(OCI.ATTR.OCI_ATTR_PREFETCH_ROWS, 0, this.ErrorHandle);
                 statementHandle.SetAttribute(OCI.ATTR.OCI_ATTR_PREFETCH_MEMORY, 0, this.ErrorHandle);
             }
         }
         OCI.MODE mode = OCI.MODE.OCI_DEFAULT;
         if (num8 == 0)
         {
             if (IsBehavior(behavior, CommandBehavior.SchemaOnly))
             {
                 mode |= OCI.MODE.OCI_DESCRIBE_ONLY;
             }
         }
         else if (this._connection.TransactionState == TransactionState.AutoCommit)
         {
             mode |= OCI.MODE.OCI_COMMIT_ON_SUCCESS;
         }
         else if (TransactionState.GlobalStarted != this._connection.TransactionState)
         {
             this._connection.TransactionState = TransactionState.LocalStarted;
         }
         if ((((mode & OCI.MODE.OCI_DESCRIBE_ONLY) == OCI.MODE.OCI_DEFAULT) && (this._parameterCollection != null)) && (this._parameterCollection.Count > 0))
         {
             int offset = 0;
             int count = this._parameterCollection.Count;
             flagArray = new bool[count];
             handleArray = new SafeHandle[count];
             bindingArray = new OracleParameterBinding[count];
             for (int i = 0; i < count; i++)
             {
                 bindingArray[i] = new OracleParameterBinding(this, this._parameterCollection[i]);
                 bindingArray[i].PrepareForBind(this._connection, ref offset);
                 if ((OracleType.Cursor == this._parameterCollection[i].OracleType) || (0 < this._parameterCollection[i].CommandSetResult))
                 {
                     if (resultParameterOrdinals == null)
                     {
                         resultParameterOrdinals = new ArrayList();
                     }
                     resultParameterOrdinals.Add(i);
                 }
             }
             parameterBuffer = new NativeBuffer_ParameterBuffer(offset);
             parameterBuffer.DangerousAddRef(ref success);
             for (int j = 0; j < count; j++)
             {
                 bindingArray[j].Bind(statementHandle, parameterBuffer, this._connection, ref flagArray[j], ref handleArray[j]);
             }
         }
         rc = TracedNativeMethods.OCIStmtExecute(this.ServiceContextHandle, statementHandle, this.ErrorHandle, num8, mode);
         if (rc != 0)
         {
             this.Connection.CheckError(this.ErrorHandle, rc);
         }
         if (bindingArray != null)
         {
             int length = bindingArray.Length;
             for (int k = 0; k < length; k++)
             {
                 bindingArray[k].PostExecute(parameterBuffer, this._connection);
                 bindingArray[k].Dispose();
                 bindingArray[k] = null;
             }
             bindingArray = null;
         }
         if (!needRowid || ((mode & OCI.MODE.OCI_DESCRIBE_ONLY) != OCI.MODE.OCI_DEFAULT))
         {
             return stmt;
         }
         switch (this._statementType)
         {
             case OCI.STMT.OCI_STMT_UPDATE:
             case OCI.STMT.OCI_STMT_DELETE:
             case OCI.STMT.OCI_STMT_INSERT:
                 rowidDescriptor = statementHandle.GetRowid(this.EnvironmentHandle, this.ErrorHandle);
                 return stmt;
         }
         rowidDescriptor = null;
     }
     finally
     {
         if (success)
         {
             parameterBuffer.DangerousRelease();
         }
         if (parameterBuffer != null)
         {
             parameterBuffer.Dispose();
             parameterBuffer = null;
         }
         if (bindingArray != null)
         {
             int num10 = bindingArray.Length;
             for (int m = 0; m < num10; m++)
             {
                 if (bindingArray[m] != null)
                 {
                     bindingArray[m].Dispose();
                     bindingArray[m] = null;
                 }
             }
             bindingArray = null;
         }
         if ((flagArray != null) && (handleArray != null))
         {
             int num9 = flagArray.Length;
             for (int n = 0; n < num9; n++)
             {
                 if (flagArray[n])
                 {
                     handleArray[n].DangerousRelease();
                 }
             }
         }
     }
     return stmt;
 }
        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);
        }
        private object ExecuteScalarInternal(bool needCLStype, bool needRowid, out OciRowidDescriptor rowidDescriptor)
        {
            OciStatementHandle statementHandle = null;
            object             oracleValue     = null;
            int rc = 0;

            try
            {
                statementHandle = this.GetStatementHandle();
                ArrayList resultParameterOrdinals = new ArrayList();
                this.Execute(statementHandle, CommandBehavior.Default, needRowid, out rowidDescriptor, out resultParameterOrdinals);
                if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
                {
                    return(oracleValue);
                }
                OracleColumn column       = new OracleColumn(statementHandle, 0, this.ErrorHandle, this._connection);
                int          offset       = 0;
                bool         success      = false;
                bool         mustRelease  = false;
                SafeHandle   handleToBind = null;
                column.Describe(ref offset, this._connection, this.ErrorHandle);
                NativeBuffer_RowBuffer buffer = new NativeBuffer_RowBuffer(offset, 1);
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    buffer.DangerousAddRef(ref success);
                    column.Bind(statementHandle, buffer, this.ErrorHandle, 0);
                    column.Rebind(this._connection, ref mustRelease, ref handleToBind);
                    rc = TracedNativeMethods.OCIStmtFetch(statementHandle, this.ErrorHandle, 1, OCI.FETCH.OCI_FETCH_NEXT, OCI.MODE.OCI_DEFAULT);
                    if (100 != rc)
                    {
                        if (rc != 0)
                        {
                            this.Connection.CheckError(this.ErrorHandle, rc);
                        }
                        if (needCLStype)
                        {
                            oracleValue = column.GetValue(buffer);
                        }
                        else
                        {
                            oracleValue = column.GetOracleValue(buffer);
                        }
                    }
                }
                finally
                {
                    if (mustRelease)
                    {
                        handleToBind.DangerousRelease();
                    }
                    if (success)
                    {
                        buffer.DangerousRelease();
                    }
                }
                GC.KeepAlive(column);
            }
            finally
            {
                if (statementHandle != null)
                {
                    this.ReleaseStatementHandle(statementHandle);
                }
            }
            return(oracleValue);
        }
        internal string Execute(OciStatementHandle statementHandle, CommandBehavior behavior, bool needRowid, out OciRowidDescriptor rowidDescriptor, out ArrayList resultParameterOrdinals)
        {
            if (this.ConnectionIsClosed)
            {
                throw System.Data.Common.ADP.ClosedConnectionError();
            }
            if ((this._transaction == null) && (this.Connection.Transaction != null))
            {
                throw System.Data.Common.ADP.TransactionRequired();
            }
            if (((this._transaction != null) && (this._transaction.Connection != null)) && (this.Connection != this._transaction.Connection))
            {
                throw System.Data.Common.ADP.TransactionConnectionMismatch();
            }
            rowidDescriptor = null;
            this.Connection.RollbackDeadTransaction();
            int          rc = 0;
            NativeBuffer parameterBuffer = null;
            bool         success         = false;

            bool[]                   flagArray    = null;
            SafeHandle[]             handleArray  = null;
            OracleParameterBinding[] bindingArray = null;
            string                   stmt         = null;

            resultParameterOrdinals = null;
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                int   num8;
                short num13;
                if (this._preparedStatementHandle != statementHandle)
                {
                    stmt = this.StatementText;
                    rc   = TracedNativeMethods.OCIStmtPrepare(statementHandle, this.ErrorHandle, stmt, OCI.SYNTAX.OCI_NTV_SYNTAX, OCI.MODE.OCI_DEFAULT, this.Connection);
                    if (rc != 0)
                    {
                        this.Connection.CheckError(this.ErrorHandle, rc);
                    }
                }
                statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_STMT_TYPE, out num13, this.ErrorHandle);
                this._statementType = (OCI.STMT)num13;
                if (OCI.STMT.OCI_STMT_SELECT != this._statementType)
                {
                    num8 = 1;
                }
                else
                {
                    num8 = 0;
                    if (CommandBehavior.SingleRow != behavior)
                    {
                        statementHandle.SetAttribute(OCI.ATTR.OCI_ATTR_PREFETCH_ROWS, 0, this.ErrorHandle);
                        statementHandle.SetAttribute(OCI.ATTR.OCI_ATTR_PREFETCH_MEMORY, 0, this.ErrorHandle);
                    }
                }
                OCI.MODE mode = OCI.MODE.OCI_DEFAULT;
                if (num8 == 0)
                {
                    if (IsBehavior(behavior, CommandBehavior.SchemaOnly))
                    {
                        mode |= OCI.MODE.OCI_DESCRIBE_ONLY;
                    }
                }
                else if (this._connection.TransactionState == TransactionState.AutoCommit)
                {
                    mode |= OCI.MODE.OCI_COMMIT_ON_SUCCESS;
                }
                else if (TransactionState.GlobalStarted != this._connection.TransactionState)
                {
                    this._connection.TransactionState = TransactionState.LocalStarted;
                }
                if ((((mode & OCI.MODE.OCI_DESCRIBE_ONLY) == OCI.MODE.OCI_DEFAULT) && (this._parameterCollection != null)) && (this._parameterCollection.Count > 0))
                {
                    int offset = 0;
                    int count  = this._parameterCollection.Count;
                    flagArray    = new bool[count];
                    handleArray  = new SafeHandle[count];
                    bindingArray = new OracleParameterBinding[count];
                    for (int i = 0; i < count; i++)
                    {
                        bindingArray[i] = new OracleParameterBinding(this, this._parameterCollection[i]);
                        bindingArray[i].PrepareForBind(this._connection, ref offset);
                        if ((OracleType.Cursor == this._parameterCollection[i].OracleType) || (0 < this._parameterCollection[i].CommandSetResult))
                        {
                            if (resultParameterOrdinals == null)
                            {
                                resultParameterOrdinals = new ArrayList();
                            }
                            resultParameterOrdinals.Add(i);
                        }
                    }
                    parameterBuffer = new NativeBuffer_ParameterBuffer(offset);
                    parameterBuffer.DangerousAddRef(ref success);
                    for (int j = 0; j < count; j++)
                    {
                        bindingArray[j].Bind(statementHandle, parameterBuffer, this._connection, ref flagArray[j], ref handleArray[j]);
                    }
                }
                rc = TracedNativeMethods.OCIStmtExecute(this.ServiceContextHandle, statementHandle, this.ErrorHandle, num8, mode);
                if (rc != 0)
                {
                    this.Connection.CheckError(this.ErrorHandle, rc);
                }
                if (bindingArray != null)
                {
                    int length = bindingArray.Length;
                    for (int k = 0; k < length; k++)
                    {
                        bindingArray[k].PostExecute(parameterBuffer, this._connection);
                        bindingArray[k].Dispose();
                        bindingArray[k] = null;
                    }
                    bindingArray = null;
                }
                if (!needRowid || ((mode & OCI.MODE.OCI_DESCRIBE_ONLY) != OCI.MODE.OCI_DEFAULT))
                {
                    return(stmt);
                }
                switch (this._statementType)
                {
                case OCI.STMT.OCI_STMT_UPDATE:
                case OCI.STMT.OCI_STMT_DELETE:
                case OCI.STMT.OCI_STMT_INSERT:
                    rowidDescriptor = statementHandle.GetRowid(this.EnvironmentHandle, this.ErrorHandle);
                    return(stmt);
                }
                rowidDescriptor = null;
            }
            finally
            {
                if (success)
                {
                    parameterBuffer.DangerousRelease();
                }
                if (parameterBuffer != null)
                {
                    parameterBuffer.Dispose();
                    parameterBuffer = null;
                }
                if (bindingArray != null)
                {
                    int num10 = bindingArray.Length;
                    for (int m = 0; m < num10; m++)
                    {
                        if (bindingArray[m] != null)
                        {
                            bindingArray[m].Dispose();
                            bindingArray[m] = null;
                        }
                    }
                    bindingArray = null;
                }
                if ((flagArray != null) && (handleArray != null))
                {
                    int num9 = flagArray.Length;
                    for (int n = 0; n < num9; n++)
                    {
                        if (flagArray[n])
                        {
                            handleArray[n].DangerousRelease();
                        }
                    }
                }
            }
            return(stmt);
        }