public override object InternalExecute(Program program, object[] arguments) { var tableVar = APIUtilities.ResolveTableVarName(program, (string)arguments[0]); var identifyingKey = APIUtilities.FindIdentifyingKey(program, tableVar); var keyValues = APIUtilities.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)); APIUtilities.Execute(program, statement, dataParams); return(null); }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = APIUtilities.ResolveTableVarName(program, (string)arguments[0]); var expression = String.Format("select {0}", tableVar.Name); return(APIUtilities.Evaluate(program, expression, tableVar, null)); }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = APIUtilities.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)); APIUtilities.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 = APIUtilities.ResolveTableVarName(plan, tableVarName); DataType = tableVar.DataType; }
public override object InternalExecute(Program program, object[] arguments) { var tableVar = APIUtilities.ResolveTableVarName(program, (string)arguments[0]); var identifyingKey = APIUtilities.FindIdentifyingKey(program, tableVar); var keyValues = APIUtilities.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(APIUtilities.EvaluateSingleton(program, expression, dataParams)); }