Beispiel #1
0
        public void FetchInto(FetchContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (!CursorInfo.IsScroll &&
                context.Direction != FetchDirection.Next)
            {
                throw new ArgumentException(String.Format("Cursor '{0}' is not SCROLL: can fetch only NEXT value.", CursorInfo.CursorName));
            }

            var table = State.Result;

            if (!CursorInfo.IsInsensitive)
            {
                table = Evaluate(context.Request, State.OpenArguments);
            }

            var fetchRow = State.FetchRowFrom(table, context.Direction, context.Offset);

            if (context.IsGlobalReference)
            {
                var reference = ((SqlReferenceExpression)context.Reference).ReferenceName;
                FetchIntoReference(context.Request, fetchRow, reference);
            }
            else if (context.IsVariableReference)
            {
                var varName = ((SqlVariableReferenceExpression)context.Reference).VariableName;
                FetchIntoVatiable(context.Request, fetchRow, varName);
            }
        }
Beispiel #2
0
        public void FetchInto(FetchContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var fetchRow = Fetch(context.Direction, context.Offset);

            if (context.IsGlobalReference)
            {
                var reference = ((SqlReferenceExpression)context.Reference).ReferenceName;

                FetchIntoReference(fetchRow, reference);
            }
            else if (context.IsVariableReference)
            {
                var varNames = context.VariableNames;
                FetchIntoVatiable(fetchRow, varNames);
            }
        }
Beispiel #3
0
        public void FetchInto(FetchContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            if (!CursorInfo.IsScroll &&
                context.Direction != FetchDirection.Next)
                throw new ArgumentException(String.Format("Cursor '{0}' is not SCROLL: can fetch only NEXT value.", CursorInfo.CursorName));

            var table = State.Result;
            if (!CursorInfo.IsInsensitive)
                table = Evaluate(context.Request, State.OpenArguments);

            var fetchRow = State.FetchRowFrom(table, context.Direction, context.Offset);

            if (context.IsGlobalReference) {
                var reference = ((SqlReferenceExpression) context.Reference).ReferenceName;
                FetchIntoReference(context.Request, fetchRow, reference);
            } else if (context.IsVariableReference) {
                var varName = ((SqlVariableReferenceExpression) context.Reference).VariableName;
                FetchIntoVatiable(context.Request, fetchRow, varName);
            }
        }
Beispiel #4
0
        protected override void ExecuteStatement(ExecutionContext context)
        {
            if (!context.Request.Context.CursorExists(CursorName))
                throw new StatementException(String.Format("The cursor '{0}' was not found in the current context.", CursorName));

            var cursor = context.Request.Context.FindCursor(CursorName);

            if (cursor == null)
                throw new StatementException(String.Format("The cursor '{0}' was not found in the current context.", CursorName));
            if (cursor.Status == CursorStatus.Closed)
                throw new StatementException(String.Format("The cursor '{0}' was already closed.", CursorName));

            int offset = -1;
            if (OffsetExpression != null)
                offset = OffsetExpression.EvaluateToConstant(context.Request, null);

            var fetchContext = new FetchContext(context.Request, Direction, ReferenceExpression);
            if (Direction == FetchDirection.Absolute ||
                Direction == FetchDirection.Relative)
                fetchContext.Offset = offset;

            cursor.FetchInto(fetchContext);
        }