public override object InternalExecute(Program program, object[] arguments) { var tableVar = RESTUtilities.ResolveTableVarName(program, (string)arguments[0]); var identifyingKey = RESTUtilities.FindIdentifyingKey(program, tableVar); var keyValues = RESTUtilities.GetKeyValues(program, identifyingKey, (string)arguments[1]); var keyEqualExpression = Compiler.BuildKeyEqualExpression(program.Plan, String.Empty, "AKey", new Schema.RowType(identifyingKey.Columns).Columns, keyValues.DataType.Columns); var updateStatement = new UpdateStatement(); updateStatement.Target = new IdentifierExpression(tableVar.Name); var row = (IRow)arguments[2]; for (int i = 0; i < row.DataType.Columns.Count; i++) { updateStatement.Columns.Add(new UpdateColumnExpression(new IdentifierExpression(row.DataType.Columns[i].Name), new IdentifierExpression(Schema.Object.Qualify(row.DataType.Columns[i].Name, "ARow")))); } updateStatement.Condition = keyEqualExpression; var statement = new D4TextEmitter().Emit(updateStatement); var dataParams = new DataParams(); dataParams.Add(new DataParam("AKey", keyValues.DataType, Modifier.In, keyValues)); dataParams.Add(new DataParam("ARow", row.DataType, Modifier.In, row)); RESTUtilities.Execute(program, statement, dataParams); return(null); }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = RESTUtilities.ResolveTableVarName(program, (string)arguments[0]); var expression = String.Format("select {0}", tableVar.Name); return(RESTUtilities.Evaluate(program, expression, tableVar, null)); }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = RESTUtilities.ResolveTableVarName(program, (string)arguments[0]); var insertStatement = new InsertStatement(new IdentifierExpression("ARow"), new IdentifierExpression(tableVar.Name)); var statement = new D4TextEmitter().Emit(insertStatement); var dataParams = new DataParams(); var row = (IRow)arguments[1]; dataParams.Add(new DataParam("ARow", row.DataType, Modifier.In, row)); RESTUtilities.Execute(program, statement, dataParams); return(null); }
public override void DetermineDataType(Plan plan) { base.DetermineDataType(plan); if (!Nodes[0].IsLiteral) { throw new CompilerException(CompilerException.Codes.LiteralArgumentRequired, "ATableName"); } var tableVarName = (string)plan.ExecuteNode(Nodes[0]); var tableVar = RESTUtilities.ResolveTableVarName(plan, tableVarName); DataType = tableVar.DataType; }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = RESTUtilities.ResolveTableVarName(program, (string)arguments[0]); var identifyingKey = RESTUtilities.FindIdentifyingKey(program, tableVar); var keyValues = RESTUtilities.GetKeyValues(program, identifyingKey, (string)arguments[1]); var keyEqualExpression = Compiler.BuildKeyEqualExpression(program.Plan, String.Empty, "AKey", new Schema.RowType(identifyingKey.Columns).Columns, keyValues.DataType.Columns); var tableVarExpression = new IdentifierExpression(tableVar.Name); var restrictExpression = new RestrictExpression(tableVarExpression, keyEqualExpression); var expression = new D4TextEmitter().Emit(restrictExpression); var dataParams = new DataParams(); dataParams.Add(new DataParam("AKey", keyValues.DataType, Modifier.In, keyValues)); return(RESTUtilities.EvaluateSingleton(program, expression, dataParams)); }