java.lang.Object
com.northconcepts.datapipeline.jdbc.sql.SqlPart
com.northconcepts.datapipeline.jdbc.sql.merge.Merge

public class Merge extends SqlPart
Builds a MERGE statement that updates the target row when the ON condition matches and inserts one otherwise; the target table is aliased target.
  • Constructor Details

    • Merge

      public Merge(String target)
  • Method Details

    • setPretty

      public Merge setPretty(boolean pretty)
      Description copied from class: SqlPart
      Indicates if SqlPart.getSqlFragment() adds line breaks and indentation instead of using one line (default is false).
      Overrides:
      setPretty in class SqlPart
    • getCondition

      public String getCondition()
      Returns the ON condition that decides between updating and inserting.
    • setCondition

      public void setCondition(String condition)
      Sets the ON condition that decides between updating and inserting.
    • addInsertValue

      public Merge addInsertValue(String columnName, Object value, boolean isInsert)
      Adds a column and its parameter value to the INSERT clause, rendered as column=? unless isInsert is true.
    • addInsertValues

      public Merge addInsertValues(String... columnNames)
      Adds columns with null parameter values to the INSERT clause.
    • addUpdateValue

      public Merge addUpdateValue(String columnName, Object value, boolean isInsert)
      Adds a column and its parameter value to the UPDATE SET clause, rendered as column=? unless isInsert is true.
    • addUpdateValue

      public Merge addUpdateValue(String columnName)
      Adds a column=? assignment with a null parameter value to the UPDATE SET clause.
    • addValue

      public Merge addValue(Object value)
    • getTarget

      public String getTarget()
    • getUsing

      public IMergeUsing getUsing()
      Returns the strategy that renders the USING clause or null if none is set.
    • setUsing

      public Merge setUsing(IMergeUsing using)
      Sets the strategy that renders the USING clause, such as MergeUsing.VALUES; required before generating the SQL.
    • collectSqlFragment

      public void collectSqlFragment(CodeWriter writer)
      Description copied from class: SqlPart
      Writes this part's SQL to the writer; used by SqlPart.getSqlFragment() and by enclosing parts.
      Specified by:
      collectSqlFragment in class SqlPart
    • collectParameterValues

      public void collectParameterValues(List<Object> values)
      Description copied from class: SqlPart
      Appends the values for this part's ? parameters to the list in order; adds nothing by default.
      Overrides:
      collectParameterValues in class SqlPart