예제 #1
0
파일: Result.cs 프로젝트: cwdotson/FwNs
        public static Result NewResult(int type)
        {
            RowSetNavigator navigator = null;

            if (type <= 0x12)
            {
                switch (type)
                {
                case 6:
                case 0x11:
                    navigator = new RowSetNavigatorClient(1);
                    break;

                case 8:
                    navigator = new RowSetNavigatorClient(4);
                    break;

                case 0x10:
                    navigator = new RowSetNavigatorClient(4);
                    break;

                case 0x12:
                    throw Error.RuntimeError(0xc9, "Result");
                }
            }
            return(new Result(type)
            {
                navigator = navigator
            });
        }
예제 #2
0
        public RowSetNavigator GetInsertSelectNavigator(Session session)
        {
            SqlType[]       columnTypes     = base.BaseTable.GetColumnTypes();
            int[]           insertColumnMap = base.InsertColumnMap;
            Result          result          = base.queryExpression.GetResult(session, 0);
            RowSetNavigator navigator       = result.InitialiseNavigator();

            SqlType[]             typeArray2 = result.MetaData.ColumnTypes;
            RowSetNavigatorClient client     = new RowSetNavigatorClient(2);

            while (navigator.HasNext())
            {
                object[] newRowData = base.BaseTable.GetNewRowData(session);
                object[] next       = navigator.GetNext();
                for (int i = 0; i < insertColumnMap.Length; i++)
                {
                    int index = insertColumnMap[i];
                    if (index != this.OverrideUserValue)
                    {
                        SqlType type = typeArray2[i];
                        newRowData[index] = columnTypes[index].ConvertToType(session, next[i], type);
                    }
                }
                client.Add(newRowData);
            }
            return(client);
        }
예제 #3
0
파일: Result.cs 프로젝트: cwdotson/FwNs
        public static Result NewDataRowsResult(RowSetNavigator navigator)
        {
            Result result1 = NewResult(14);

            result1.navigator = navigator;
            return(result1);
        }
예제 #4
0
파일: Result.cs 프로젝트: cwdotson/FwNs
 public static Result NewResult(RowSetNavigator nav)
 {
     return(new Result(3)
     {
         navigator = nav
     });
 }
예제 #5
0
 private void SetReturnParameterValue(Result resultIn)
 {
     if (resultIn.IsData())
     {
         foreach (UtlParameter parameter in this._command.Parameters)
         {
             if (parameter.Direction == ParameterDirection.ReturnValue)
             {
                 RowSetNavigator navigator = resultIn.GetNavigator();
                 if (navigator.Next())
                 {
                     object[] current = navigator.GetCurrent();
                     if (current.Length != 0)
                     {
                         SqlType sourceType = resultIn.MetaData.ColumnTypes[0];
                         SqlType utlType    = SqlType.GetUtlType(parameter.UtlType);
                         parameter.Value = this.GetColumnInType(current[0], sourceType, utlType);
                     }
                 }
                 break;
             }
         }
         resultIn.GetNavigator().Reset();
     }
 }
예제 #6
0
 public Cursor(StatementQuery queryStatement) : base(100)
 {
     base.nodes           = Expression.emptyArray;
     this._queryStatement = queryStatement;
     base.DataType        = SqlType.SqlAllTypes;
     this._state          = CursorState.Closed;
     this._result         = null;
     this._navigator      = null;
 }
예제 #7
0
        protected void WriteSingleColumnResult(Result r)
        {
            RowSetNavigator navigator = r.InitialiseNavigator();

            while (navigator.HasNext())
            {
                object[] next = navigator.GetNext();
                this.WriteLogStatement(this.CurrentSession, (string)next[0]);
            }
        }
예제 #8
0
        private void ClearResultStructures(Result result)
        {
            result.SetStatement(null);
            RowSetNavigator navigator = result.GetNavigator();

            if (navigator != null)
            {
                navigator.ClearStructures();
            }
        }
예제 #9
0
        public RowSetNavigatorClient GetRowSetSlice(long id, int offset, int count)
        {
            RowSetNavigator source = this._resultMap[id].GetNavigator();

            if ((offset + count) > source.GetSize())
            {
                count = source.GetSize() - offset;
            }
            return(new RowSetNavigatorClient(source, offset, count));
        }
예제 #10
0
        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();
            }
        }
예제 #11
0
 public int GetLobCount()
 {
     lock (this)
     {
         this._sysLobSession.sessionContext.PushDynamicArguments(new object[0]);
         this._sysLobSession.sessionContext.Pop(false);
         RowSetNavigator navigator = this._getLobCount.Execute(this._sysLobSession).GetNavigator();
         if (!navigator.Next())
         {
             navigator.Close();
             return(0);
         }
         return(Convert.ToInt32(navigator.GetCurrent()[0]));
     }
 }
예제 #12
0
 public void Open(Session session, string cursorName)
 {
     this.CheckClosed(cursorName);
     this._result = this._queryStatement.Execute(session);
     if (this._result.IsError())
     {
         throw this._result.GetException();
     }
     if (!this._result.IsData())
     {
         throw Error.GetError(0xe10);
     }
     this._navigator = this._result.GetNavigator();
     this._state     = CursorState.Open;
 }
예제 #13
0
        private long GetNewLobId()
        {
            Result result = this._getNextLobId.Execute(this._sysLobSession);

            if (result.IsError())
            {
                return(0L);
            }
            RowSetNavigator navigator = result.GetNavigator();

            if (!navigator.Next())
            {
                navigator.Close();
                return(0L);
            }
            return(Convert.ToInt64(navigator.GetCurrent()[0]));
        }
예제 #14
0
 public override void InsertValuesIntoSubqueryTable(Session session, IPersistentStore store)
 {
     if (!this._isTable)
     {
         object[] objArray2 = (object[])base.nodes[0].GetValue(session);
         for (int i = 0; i < objArray2.Length; i++)
         {
             object[] objArray3;
             if (this._ordinality)
             {
                 objArray3 = new object[] { objArray2[i], i };
             }
             else
             {
                 objArray3 = new object[] { objArray2[i] };
             }
             Row newCachedObject = store.GetNewCachedObject(session, objArray3);
             try
             {
                 store.IndexRow(session, newCachedObject);
             }
             catch (CoreException)
             {
             }
         }
     }
     else
     {
         RowSetNavigator navigator = base.nodes[0].GetResult(session).GetNavigator();
         while (navigator.HasNext())
         {
             object[] next            = navigator.GetNext();
             Row      newCachedObject = store.GetNewCachedObject(session, next);
             try
             {
                 store.IndexRow(session, newCachedObject);
                 continue;
             }
             catch (CoreException)
             {
                 continue;
             }
         }
     }
 }
예제 #15
0
        public void SendResultsEnd()
        {
            if (this._recordList == null)
            {
                throw new InvalidOperationException();
            }
            if (this._recordList.Count == 0)
            {
                throw new InvalidOperationException();
            }
            Result          result    = Result.NewDataResult(GetResultMetaData(this._recordList[0]));
            RowSetNavigator navigator = result.InitialiseNavigator();

            foreach (UtlDataRecord record in this._recordList)
            {
                navigator.Add(record.GetValuesDuplicate());
            }
            this._session.AddResultSet(result);
            this._recordList = null;
        }
예제 #16
0
        private int[][] GetBlockAddresses(long lobId, int offset, int limit)
        {
            object[] args = new object[this._getLobPart.GetParametersMetaData().GetColumnCount()];
            args[0] = lobId;
            args[1] = offset;
            args[2] = limit;
            this._sysLobSession.sessionContext.PushDynamicArguments(args);
            this._sysLobSession.sessionContext.Pop(false);
            RowSetNavigator navigator = this._getLobPart.Execute(this._sysLobSession).GetNavigator();
            int             size      = navigator.GetSize();

            int[][] numArray = new int[size][];
            for (int i = 0; i < size; i++)
            {
                navigator.Absolute(i);
                object[] current = navigator.GetCurrent();
                numArray[i] = new int[] { Convert.ToInt32(current[0]), Convert.ToInt32(current[1]), Convert.ToInt32(current[2]) };
            }
            navigator.Close();
            return(numArray);
        }
예제 #17
0
        private object[] GetLobHeader(long lobId)
        {
            object[] args = new object[this._getLob.GetParametersMetaData().GetColumnCount()];
            args[0] = lobId;
            this._sysLobSession.sessionContext.PushDynamicArguments(args);
            Result result = this._getLob.Execute(this._sysLobSession);

            this._sysLobSession.sessionContext.Pop(false);
            if (result.IsError())
            {
                return(null);
            }
            RowSetNavigator navigator = result.GetNavigator();

            if (!navigator.Next())
            {
                navigator.Close();
                return(null);
            }
            return(navigator.GetCurrent());
        }
예제 #18
0
 public override bool Read()
 {
     this.CheckClosed();
     if (this._readingState == 2)
     {
         return(false);
     }
     if ((this._rResult == null) || this._rResult.GetNavigator().IsEmpty())
     {
         this._readingState = 1;
         return(false);
     }
     if (!this._bInit)
     {
         this._nCurrent = this._rResult.GetNavigator();
         this._nCurrent.GetNext();
         this._bInit       = true;
         this._iCurrentRow = 1;
     }
     else if ((this._commandBehavior & CommandBehavior.SingleRow) == CommandBehavior.Default)
     {
         if (this._nCurrent == null)
         {
             return(false);
         }
         this._nCurrent.GetNext();
         this._iCurrentRow++;
     }
     else
     {
         this._nCurrent = null;
     }
     if (this._nCurrent.IsAfterLast())
     {
         this._iCurrentRow  = this._rResult.GetNavigator().Size + 1;
         this._readingState = 1;
         return(false);
     }
     return(true);
 }
예제 #19
0
        public override Result GetResult(Session session)
        {
            Result           result             = null;
            RowSetNavigator  generatedNavigator = null;
            IPersistentStore rowStore           = base.BaseTable.GetRowStore(session);

            if (base.GeneratedIndexes != null)
            {
                result             = Result.NewUpdateCountResult(base.generatedResultMetaData, 0);
                generatedNavigator = result.GetChainedResult().GetNavigator();
            }
            if (this.IsSimpleInsert)
            {
                SqlType[] columnTypes = base.BaseTable.GetColumnTypes();
                object[]  data        = base.GetInsertData(session, columnTypes, base.InsertExpression.nodes[0].nodes);
                return(base.InsertSingleRow(session, rowStore, data));
            }
            RowSetNavigator newData = (base.queryExpression == null) ? this.GetInsertValuesNavigator(session) : this.GetInsertSelectNavigator(session);

            if (newData.GetSize() > 0)
            {
                base.InsertRowSet(session, generatedNavigator, newData);
            }
            if (base.BaseTable.TriggerLists[0].Length != 0)
            {
                base.BaseTable.FireTriggers(session, 0, newData);
            }
            if (result == null)
            {
                result = new Result(1, newData.GetSize());
            }
            else
            {
                result.SetUpdateCount(newData.GetSize());
            }
            return(result);
        }
예제 #20
0
파일: Routine.cs 프로젝트: cwdotson/FwNs
 public Result InvokeClrMethod(Session session, object[] data)
 {
     try
     {
         object obj2;
         if (this.DataImpact == 1)
         {
             session.sessionContext.IsReadOnly = true;
             session.SetNoSql();
         }
         else if (this.DataImpact == 2)
         {
             session.sessionContext.IsReadOnly = true;
         }
         else if (this.DataImpact == 3)
         {
             session.sessionContext.IsReadOnly = true;
         }
         try
         {
             UtlContext.session = session;
             obj2 = this._cSharpMethod.Invoke(this.CSharpClassInstance, data);
         }
         finally
         {
             UtlContext.session = null;
         }
         if (this.ReturnsTable())
         {
             IEnumerable enumerable = obj2 as IEnumerable;
             if ((obj2 == null) || (enumerable == null))
             {
                 throw Error.RuntimeError(0xc9, "FunctionSQLInvoked");
             }
             ResultMetaData  resultTableMetaData = this.GetResultTableMetaData();
             Result          result          = Result.NewDataResult(resultTableMetaData);
             RowSetNavigator navigator       = result.InitialiseNavigator();
             object[]        fillRowTemplate = this.GetFillRowTemplate();
             foreach (object obj3 in enumerable)
             {
                 object[] objArray2 = new object[resultTableMetaData.GetColumnCount()];
                 fillRowTemplate[0] = obj3;
                 this.FillRowMethod.Invoke(this.CSharpClassInstance, fillRowTemplate);
                 for (int i = 0; i < objArray2.Length; i++)
                 {
                     objArray2[i] = fillRowTemplate[i + 1];
                 }
                 navigator.Add(objArray2);
             }
             return(result);
         }
         return(Result.NewPsmResult(this.ReturnType.ConvertCSharpToSQL(session, obj2)));
     }
     catch (TargetInvocationException)
     {
         return(Result.NewErrorResult(Error.GetError(0x1770, this.GetName().Name), null));
     }
     catch (Exception)
     {
         return(Result.NewErrorResult(Error.GetError(0x1770, this.GetName().Name), null));
     }
 }
예제 #21
0
파일: Result.cs 프로젝트: cwdotson/FwNs
 public void SetNavigator(RowSetNavigator navigator)
 {
     this.navigator = navigator;
 }
예제 #22
0
        public Result ExecuteMergeStatement(Session session)
        {
            SqlType[]       columnTypes        = base.BaseTable.GetColumnTypes();
            Result          result             = null;
            RowSetNavigator generatedNavigator = null;

            if (base.GeneratedIndexes != null)
            {
                result             = Result.NewUpdateCountResult(base.generatedResultMetaData, 0);
                generatedNavigator = result.GetChainedResult().GetNavigator();
            }
            int count = 0;
            RowSetNavigatorClient     newData   = new RowSetNavigatorClient(8);
            RowSetNavigatorDataChange navigator = new RowSetNavigatorDataChange();

            RangeVariable[]  targetRangeVariables = base.TargetRangeVariables;
            IRangeIterator[] iteratorArray        = new IRangeIterator[targetRangeVariables.Length];
            for (int i = 0; i < targetRangeVariables.Length; i++)
            {
                iteratorArray[i] = targetRangeVariables[i].GetIterator(session);
            }
            int index = 0;

            while (index >= 0)
            {
                IRangeIterator iterator = iteratorArray[index];
                bool           flag     = iterator.IsBeforeFirst();
                if (iterator.Next())
                {
                    if (index < (targetRangeVariables.Length - 1))
                    {
                        index++;
                        continue;
                    }
                    if (base.UpdateExpressions.Length == 0)
                    {
                        continue;
                    }
                    Row      currentRow = iterator.GetCurrentRow();
                    object[] data       = GetUpdatedData(session, this._targets, base.BaseTable, base.UpdateColumnMap, base.UpdateExpressions, columnTypes, currentRow.RowData);
                    try
                    {
                        navigator.AddRow(session, currentRow, data, columnTypes, base.UpdateColumnMap);
                        continue;
                    }
                    catch (CoreException)
                    {
                        for (int k = 0; k < targetRangeVariables.Length; k++)
                        {
                            iteratorArray[k].Reset();
                        }
                        throw Error.GetError(0xc81);
                    }
                }
                if (((index == 1) & flag) && (base.InsertExpression != null))
                {
                    object[] data = this.GetInsertData(session, columnTypes, base.InsertExpression.nodes[0].nodes);
                    if (data != null)
                    {
                        newData.Add(data);
                    }
                }
                iterator.Reset();
                index--;
            }
            for (int j = 0; j < targetRangeVariables.Length; j++)
            {
                iteratorArray[j].Reset();
            }
            if (base.UpdateExpressions.Length != 0)
            {
                count = this.Update(session, base.BaseTable, navigator);
            }
            if (newData.GetSize() > 0)
            {
                this.InsertRowSet(session, generatedNavigator, newData);
                count += newData.GetSize();
            }
            if ((base.InsertExpression != null) && (base.BaseTable.TriggerLists[0].Length != 0))
            {
                base.BaseTable.FireTriggers(session, 0, newData);
            }
            if (result != null)
            {
                result.SetUpdateCount(count);
                return(result);
            }
            if (count == 1)
            {
                return(Result.UpdateOneResult);
            }
            return(new Result(1, count));
        }