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