public void InsertRowSet(Session session, RowSetNavigator generatedNavigator, RowSetNavigator newData) { IPersistentStore rowStore = base.BaseTable.GetRowStore(session); IRangeIterator iterator = null; if (this.UpdatableTableCheck != null) { iterator = this._checkRangeVariable.GetIterator(session); } newData.BeforeFirst(); if (base.BaseTable.TriggerLists[6].Length != 0) { while (newData.HasNext()) { object[] next = newData.GetNext(); base.BaseTable.FireTriggers(session, 6, null, next, null); } newData.BeforeFirst(); } while (newData.HasNext()) { object[] next = newData.GetNext(); base.BaseTable.InsertSingleRow(session, rowStore, next, null); if (iterator != null) { iterator.SetCurrent(next); if (!this.UpdatableTableCheck.TestCondition(session)) { throw Error.GetError(0x1644); } } if (generatedNavigator != null) { object[] generatedColumns = base.GetGeneratedColumns(next); generatedNavigator.Add(generatedColumns); } } newData.BeforeFirst(); while (newData.HasNext()) { object[] next = newData.GetNext(); PerformIntegrityChecks(session, base.BaseTable, null, next, null); } newData.BeforeFirst(); if (base.BaseTable.TriggerLists[3].Length != 0) { while (newData.HasNext()) { object[] next = newData.GetNext(); base.BaseTable.FireTriggers(session, 3, null, next, null); } newData.BeforeFirst(); } }
public Result ExecuteUpdateStatement(Session session) { Expression[] updateExpressions = base.UpdateExpressions; RowSetNavigatorDataChange navigator = new RowSetNavigatorDataChange(); SqlType[] columnTypes = base.BaseTable.GetColumnTypes(); IRangeIterator iterator = RangeVariable.GetIterator(session, base.TargetRangeVariables); while (iterator.Next()) { session.sessionData.StartRowProcessing(); Row currentRow = iterator.GetCurrentRow(); object[] rowData = currentRow.RowData; object[] data = GetUpdatedData(session, this._targets, base.BaseTable, base.UpdateColumnMap, updateExpressions, columnTypes, rowData); if (this.UpdatableTableCheck != null) { iterator.SetCurrent(data); if (!this.UpdatableTableCheck.TestCondition(session)) { iterator.Release(); throw Error.GetError(0x1644); } } navigator.AddRow(session, currentRow, data, columnTypes, base.UpdateColumnMap); } iterator.Release(); navigator.BeforeFirst(); int count = this.Update(session, base.BaseTable, navigator); switch (count) { case 1: return(Result.UpdateOneResult); case 0: return(Result.UpdateZeroResult); } return(new Result(1, count)); }