protected override void BuildUpdateSet(SelectQuery selectQuery, SqlUpdateClause updateClause)
        {
            AppendIndent()
            .AppendLine("SET");

            Indent++;

            var first = true;

            foreach (var expr in updateClause.Items)
            {
                if (!first)
                {
                    StringBuilder.Append(',').AppendLine();
                }
                first = false;

                AppendIndent();

                BuildExpression(expr.Column, SqlProviderFlags.IsUpdateSetTableAliasSupported, true, false);
                StringBuilder.Append(" = ");

                var addAlias = false;

                BuildColumnExpression(selectQuery, expr.Expression, null, ref addAlias, false);
            }

            Indent--;

            StringBuilder.AppendLine();
        }
Ejemplo n.º 2
0
 protected override void BuildUpdateTableName(SelectQuery selectQuery, SqlUpdateClause updateClause)
 {
     if (updateClause.Table != null && (selectQuery.From.Tables.Count == 0 || updateClause.Table != selectQuery.From.Tables[0].Source))
     {
         BuildPhysicalTable(updateClause.Table, null);
     }
     else
     {
         BuildTableName(selectQuery.From.Tables[0], true, false);
     }
 }
Ejemplo n.º 3
0
        protected override void BuildUpdateTableName(SelectQuery selectQuery, SqlUpdateClause updateClause)
        {
            var table = updateClause.Table != null ?
                        (selectQuery.From.FindTableSource(updateClause.Table) ?? updateClause.Table) :
                        selectQuery.From.Tables[0];

            if (table is SqlTable)
            {
                BuildPhysicalTable(table, null);
            }
            else
            {
                StringBuilder.Append(Convert(GetTableAlias(table), ConvertType.NameToQueryTableAlias));
            }
        }
        protected override void BuildMergeOperationUpdateBySource(SqlMergeOperationClause operation)
        {
            StringBuilder
            .AppendLine()
            .Append("WHEN NOT MATCHED By Source");

            if (operation.Where != null)
            {
                StringBuilder.Append(" AND ");
                BuildSearchCondition(Precedence.Unknown, operation.Where, wrapCondition: true);
            }

            StringBuilder.AppendLine(" THEN UPDATE");

            var update = new SqlUpdateClause();

            update.Items.AddRange(operation.Items);
            BuildUpdateSet(null, update);
        }
Ejemplo n.º 5
0
        protected virtual void BuildMergeOperationUpdate(SqlMergeOperationClause operation)
        {
            StringBuilder
            .AppendLine()
            .Append("WHEN MATCHED");

            if (operation.Where != null)
            {
                StringBuilder.Append(" AND ");
                BuildSearchCondition(Precedence.Unknown, operation.Where);
            }

            StringBuilder.AppendLine(" THEN");
            StringBuilder.AppendLine("UPDATE");

            var update = new SqlUpdateClause();

            update.Items.AddRange(operation.Items);
            BuildUpdateSet(null, update);
        }
Ejemplo n.º 6
0
 protected override void BuildUpdateClause(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)
 {
     base.BuildFromClause(statement, selectQuery);
     StringBuilder.Remove(0, 4).Insert(0, "UPDATE");
     base.BuildUpdateSet(selectQuery, updateClause);
 }
Ejemplo n.º 7
0
        protected override void BuildUpdateClause(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause)
        {
            base.BuildUpdateClause(statement, selectQuery, updateClause);

            var output = statement.GetOutputClause();

            BuildOutputSubclause(output);
        }
Ejemplo n.º 8
0
 public virtual void Visiting(SqlUpdateClause updateClause)
 {
     sqlBuilder.Append("Update " + EncapsulateTable(updateClause.SqlTable.Name));
 }
Ejemplo n.º 9
0
 public virtual void Visited(SqlUpdateClause updateClause)
 {
 }
Ejemplo n.º 10
0
 protected override void BuildUpdateQuery(SqlStatement statement, SelectQuery selectQuery, SqlUpdateClause updateClause) {
   if (statement.GetWithClause() != null) {
     throw new NotSupportedException("iSeries doesn't support Cte in Update statement");
   }
   base.BuildUpdateQuery(statement, selectQuery, updateClause);
 }