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); }
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); }
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); }
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); }
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); }