예제 #1
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException();

                var cursor = new NativeCursor(new NativeCursorInfo(QueryPlan), context.Request);

                var firstRow = cursor.FirstOrDefault();

                if (firstRow == null)
                {
                    // TODO: Is it correct to throw an error here?
                    throw new StatementException("The query has returned no elements");
                }

                if (firstRow.ColumnCount != VariableNames.Length)
                {
                    throw new StatementException("The selected number of items does not match with the number of destination variables.");
                }

                for (int i = 0; i < VariableNames.Length; i++)
                {
                    var variableName = VariableNames[i];
                    var variable     = context.Request.Context.FindVariable(variableName);
                    if (variable == null)
                    {
                        throw new ObjectNotFoundException(new ObjectName(variableName));
                    }

                    var source = firstRow.GetValue(i);
                    variable.SetValue(source);
                }

                context.SetResult(1);
            }
예제 #2
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException();

                var cursor = new NativeCursor(new NativeCursorInfo(QueryPlan), context.Request);

                var table = context.Request.Access().GetMutableTable(TableName);

                if (table == null)
                {
                    throw new StatementException(String.Format("Referenced table of the INTO statement '{0}' was not found or is not mutable.", TableName));
                }

                int count;

                try {
                    context.Query.Session.Enter(table, AccessType.Write);

                    count = InsertIntoTable(table, cursor);
                } finally {
                    context.Query.Session.Exit(table, AccessType.Write);
                }

                context.SetResult(count);
            }
예제 #3
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                // TODO: Verify if a native cursor is already opened..

                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException(String.Format("The user '{0}' has not enough rights to select from the query.", context.User.Name));

                var cursorInfo   = new NativeCursorInfo(QueryPlan, ForUpdate);
                var nativeCursor = new NativeCursor(cursorInfo, context.Request);

                context.SetCursor(nativeCursor);
            }
예제 #4
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                // TODO: Verify if a native cursor is already opened..

                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException(String.Format("The user '{0}' has not enough rights to select from the query.", context.User.Name));

                var cursorInfo = new NativeCursorInfo(QueryPlan, ForUpdate);
                var nativeCursor = new NativeCursor(cursorInfo, context.Request);

                context.SetCursor(nativeCursor);
            }
예제 #5
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException();

                var cursor = new NativeCursor(new NativeCursorInfo(QueryPlan), context.Request);

                var firstRow = cursor.FirstOrDefault();
                if (firstRow == null)
                    // TODO: Is it correct to throw an error here?
                    throw new StatementException("The query has returned no elements");

                if (firstRow.ColumnCount != VariableNames.Length)
                    throw new StatementException("The selected number of items does not match with the number of destination variables.");

                for (int i = 0; i < VariableNames.Length; i++) {
                    var variableName = VariableNames[i];
                    var variable = context.Request.Context.FindVariable(variableName);
                    if (variable == null)
                        throw new ObjectNotFoundException(new ObjectName(variableName));

                    var source = firstRow.GetValue(i);
                    variable.SetValue(source);
                }

                context.SetResult(1);
            }
예제 #6
0
            protected override void ExecuteStatement(ExecutionContext context)
            {
                //if (!context.User.CanSelectFrom(QueryPlan))
                //	throw new SecurityException();

                var cursor = new NativeCursor(new NativeCursorInfo(QueryPlan), context.Request);

                var table = context.Request.Access().GetMutableTable(TableName);
                if (table == null)
                    throw new StatementException(String.Format("Referenced table of the INTO statement '{0}' was not found or is not mutable.", TableName));

                int count;

                try {
                    context.Query.Session.Enter(table, AccessType.Write);

                    count = InsertIntoTable(table, cursor);
                } finally {
                    context.Query.Session.Exit(table, AccessType.Write);
                }

                context.SetResult(count);
            }