protected override void ExecuteStatement(ExecutionContext context) { // We have to execute the plan to get the TableInfo that represents the // result of the view execution. var table = QueryPlan.Evaluate(context.Request); var tableInfo = table.TableInfo.Alias(ViewName); var viewInfo = new ViewInfo(tableInfo, QueryExpression, QueryPlan); context.Request.Query.DefineView(viewInfo, ReplaceIfExists); }
protected override void ExecuteStatement(ExecutionContext context) { var result = QueryPlan.Evaluate(context.Request); if (IsForTable) { var table = context.Request.Query.GetMutableTable(Table); if (table == null) { throw new StatementPrepareException(String.Format("Referenced table of the INTO statement '{0}' was not found or is not mutable.", Table)); } SelectIntoTable(table, result); } // TODO: get the variable from ref and check if the result is compatible and set it throw new NotImplementedException(); }
protected override void ExecuteStatement(ExecutionContext context) { var insertTable = context.Request.Access().GetMutableTable(TableName); if (insertTable == null) { throw new ObjectNotFoundException(TableName); } var insertCount = 0; // Insert rows from the result select table. var result = QueryPlan.Evaluate(context.Request); if (result.ColumnCount() != ColumnIndices.Length) { throw new InvalidOperationException("Number of columns in result does not match columns to insert."); } foreach (var insertRow in result) { var newRow = insertTable.NewRow(); for (int n = 0; n < ColumnIndices.Length; ++n) { var cell = insertRow.GetValue(n); newRow.SetValue(ColumnIndices[n], cell); } newRow.SetDefault(context.Request); insertTable.AddRow(newRow); ++insertCount; } context.SetResult(insertCount); }
protected override void ExecuteStatement(ExecutionContext context) { //var columnNames = Columns.Select(x => x.ReferenceExpression) // .Cast<SqlReferenceExpression>() // .Select(x => x.ReferenceName.Name).ToArray(); //if (!context.User.CanUpdateTable(TableName)) // throw new MissingPrivilegesException(context.User.Name, TableName, Privileges.Update); //if (!context.User.CanSelectFrom(QueryPlan)) // throw new InvalidOperationException(); var table = context.DirectAccess.GetMutableTable(TableName); if (table == null) { throw new ObjectNotFoundException(TableName); } var updateSet = QueryPlan.Evaluate(context.Request); var updateCount = table.Update(context.Request, updateSet, Columns, Limit); context.SetResult(updateCount); }