Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public Result ExecuteDeleteStatement(Session session)
        {
            IRangeIterator            iterator  = RangeVariable.GetIterator(session, base.TargetRangeVariables);
            RowSetNavigatorDataChange navigator = new RowSetNavigatorDataChange();

            while (iterator.Next())
            {
                Row currentRow = iterator.GetCurrentRow();
                navigator.AddRow(currentRow);
            }
            iterator.Release();
            if (navigator.GetSize() <= 0)
            {
                return(Result.UpdateZeroResult);
            }
            int count = Delete(session, base.BaseTable, navigator);

            if (count == 1)
            {
                return(Result.UpdateOneResult);
            }
            return(new Result(1, count));
        }