private bool ReadInternal()
 {
     int num;
     bool flag;
     if (this._endOfData)
     {
         return false;
     }
     int length = this._columnInfo.Length;
     NativeBuffer_RowBuffer buffer = this._buffer;
     bool success = false;
     bool[] flagArray = new bool[length];
     SafeHandle[] handleArray = new SafeHandle[length];
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         if (buffer == null)
         {
             int rowBufferLength = (this._rowsToPrefetch > 1) ? this._rowBufferLength : 0;
             buffer = new NativeBuffer_RowBuffer(this._rowBufferLength, this._rowsToPrefetch);
             buffer.DangerousAddRef(ref success);
             for (num = 0; num < length; num++)
             {
                 this._columnInfo[num].Bind(this._statementHandle, buffer, this.ErrorHandle, rowBufferLength);
             }
             this._buffer = buffer;
         }
         else
         {
             buffer.DangerousAddRef(ref success);
         }
         if (buffer.MoveNext())
         {
             return true;
         }
         if (this._isLastBuffer)
         {
             this._endOfData = true;
             return false;
         }
         buffer.MoveFirst();
         if (1 == this._rowsToPrefetch)
         {
             for (num = 0; num < length; num++)
             {
                 this._columnInfo[num].Rebind(this._connection, ref flagArray[num], ref handleArray[num]);
             }
         }
         int rc = TracedNativeMethods.OCIStmtFetch(this._statementHandle, this.ErrorHandle, this._rowsToPrefetch, OCI.FETCH.OCI_FETCH_NEXT, OCI.MODE.OCI_DEFAULT);
         int num5 = this._rowsTotal;
         this._statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ROW_COUNT, out this._rowsTotal, this.ErrorHandle);
         if (rc == 0)
         {
             return true;
         }
         if (1 == rc)
         {
             this._connection.CheckError(this.ErrorHandle, rc);
             return true;
         }
         if (100 == rc)
         {
             int num4 = this._rowsTotal - num5;
             if (num4 == 0)
             {
                 if (this._rowsTotal == 0)
                 {
                     this._hasRows = 1;
                 }
                 this._endOfData = true;
                 return false;
             }
             buffer.NumberOfRows = num4;
             this._isLastBuffer = true;
             return true;
         }
         this._endOfData = true;
         this._connection.CheckError(this.ErrorHandle, rc);
         flag = false;
     }
     finally
     {
         if (1 == this._rowsToPrefetch)
         {
             for (num = 0; num < length; num++)
             {
                 if (flagArray[num])
                 {
                     handleArray[num].DangerousRelease();
                 }
             }
         }
         if (success)
         {
             buffer.DangerousRelease();
         }
     }
     return flag;
 }
Exemplo n.º 2
0
        private bool ReadInternal()
        {
            int  num;
            bool flag;

            if (this._endOfData)
            {
                return(false);
            }
            int length = this._columnInfo.Length;
            NativeBuffer_RowBuffer buffer = this._buffer;
            bool success = false;

            bool[]       flagArray   = new bool[length];
            SafeHandle[] handleArray = new SafeHandle[length];
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (buffer == null)
                {
                    int rowBufferLength = (this._rowsToPrefetch > 1) ? this._rowBufferLength : 0;
                    buffer = new NativeBuffer_RowBuffer(this._rowBufferLength, this._rowsToPrefetch);
                    buffer.DangerousAddRef(ref success);
                    for (num = 0; num < length; num++)
                    {
                        this._columnInfo[num].Bind(this._statementHandle, buffer, this.ErrorHandle, rowBufferLength);
                    }
                    this._buffer = buffer;
                }
                else
                {
                    buffer.DangerousAddRef(ref success);
                }
                if (buffer.MoveNext())
                {
                    return(true);
                }
                if (this._isLastBuffer)
                {
                    this._endOfData = true;
                    return(false);
                }
                buffer.MoveFirst();
                if (1 == this._rowsToPrefetch)
                {
                    for (num = 0; num < length; num++)
                    {
                        this._columnInfo[num].Rebind(this._connection, ref flagArray[num], ref handleArray[num]);
                    }
                }
                int rc   = TracedNativeMethods.OCIStmtFetch(this._statementHandle, this.ErrorHandle, this._rowsToPrefetch, OCI.FETCH.OCI_FETCH_NEXT, OCI.MODE.OCI_DEFAULT);
                int num5 = this._rowsTotal;
                this._statementHandle.GetAttribute(OCI.ATTR.OCI_ATTR_ROW_COUNT, out this._rowsTotal, this.ErrorHandle);
                if (rc == 0)
                {
                    return(true);
                }
                if (1 == rc)
                {
                    this._connection.CheckError(this.ErrorHandle, rc);
                    return(true);
                }
                if (100 == rc)
                {
                    int num4 = this._rowsTotal - num5;
                    if (num4 == 0)
                    {
                        if (this._rowsTotal == 0)
                        {
                            this._hasRows = 1;
                        }
                        this._endOfData = true;
                        return(false);
                    }
                    buffer.NumberOfRows = num4;
                    this._isLastBuffer  = true;
                    return(true);
                }
                this._endOfData = true;
                this._connection.CheckError(this.ErrorHandle, rc);
                flag = false;
            }
            finally
            {
                if (1 == this._rowsToPrefetch)
                {
                    for (num = 0; num < length; num++)
                    {
                        if (flagArray[num])
                        {
                            handleArray[num].DangerousRelease();
                        }
                    }
                }
                if (success)
                {
                    buffer.DangerousRelease();
                }
            }
            return(flag);
        }
 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 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);
        }