org.h2.command.dml

## Class MergeUsing

- java.lang.Object
- - org.h2.command.Prepared
  - - org.h2.command.dml.MergeUsing

All Implemented Interfaces:
  DataChangeStatement

    public class MergeUsing
    extends Prepared
    implements DataChangeStatement

This class represents the statement syntax MERGE INTO table alias USING... It does not replace the MERGE INTO... KEYS... form.

### Nested Class Summary

Nested Classes
`static class` `MergeUsing.When` Abstract WHEN command of the MERGE statement.
`static class` `MergeUsing.WhenMatched`
`static class` `MergeUsing.WhenNotMatched`

### Field Summary

### Fields inherited from class org.h2.command.Prepared

`create, parameters, prepareAlways, session, sqlStatement`

### Constructor Summary

Constructors
Constructor and Description
`MergeUsing(Session session, TableFilter targetTableFilter)`

### Method Summary

Methods
`void` `addWhen(MergeUsing.When w)` Adds WHEN command.
`void` `collectDependencies(java.util.HashSet<DbObject> dependencies)` Find and collect all DbObjects, this Prepared depends on.
`Expression` `getOnCondition()`
`java.lang.String` `getPlanSQL(boolean alwaysQuote)` Get the SQL statement with the execution plan.
`Query` `getQuery()`
`java.lang.String` `getQueryAlias()`
`TableFilter` `getSourceTableFilter()`
`java.lang.String` `getStatementName()` Return the name of this statement.
`Table` `getTable()` Return the target table.
`Table` `getTargetTable()`
`TableFilter` `getTargetTableFilter()`
`int` `getType()` Get the command type as defined in CommandInterface
`java.util.ArrayList<MergeUsing.When>` `getWhen()`
`boolean` `hasCombinedMatchedClause()` Whether any of the "when" parts contain both an update and a delete part.
`boolean` `isTransactional()` Check if this command is transactional.
`protected void` `merge(Row sourceRow)` Merge the given row.
`void` `prepare()` Prepare this statement.
`ResultInterface` `queryMeta()` Get an empty result set containing the meta data.
`void` `setDeltaChangeCollector(ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)` Set the delta change collector and collection mode.
`void` `setOnCondition(Expression condition)`
`void` `setQuery(Query query)`
`void` `setQueryAlias(java.lang.String alias)`
`void` `setSourceTableFilter(TableFilter sourceTableFilter)`
`void` `setTargetTable(Table targetTable)`
`void` `setTargetTableFilter(TableFilter targetTableFilter)`
`int` `update()` Execute the statement.

### Methods inherited from class org.h2.command.Prepared

`checkCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getSession, getSimpleSQL, getSQL, getSQL, isCacheable, isQuery, isReadOnly, needRecompile, query, setCommand, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.command.dml.DataChangeStatement

`getSQL`

### Constructor Detail

#### MergeUsing

    public MergeUsing(Session session,
              TableFilter targetTableFilter)

### Method Detail

#### setDeltaChangeCollector

    public void setDeltaChangeCollector(ResultTarget deltaChangeCollector,
                               DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)

Description copied from interface: `DataChangeStatement`
Set the delta change collector and collection mode.

Specified by:
  `setDeltaChangeCollector` in interface `DataChangeStatement`
Parameters:
  `deltaChangeCollector` - target result
  `deltaChangeCollectionMode` - collection mode

#### update

    public int update()

Description copied from class: `Prepared`
Execute the statement.

Specified by:
  `update` in interface `DataChangeStatement`
Overrides:
  `update` in class `Prepared`
Returns:
  the update count

#### merge

    protected void merge(Row sourceRow)

Merge the given row.

Parameters:
  `sourceRow` - the row

#### getPlanSQL

    public java.lang.String getPlanSQL(boolean alwaysQuote)

Description copied from class: `Prepared`
Get the SQL statement with the execution plan.

Overrides:
  `getPlanSQL` in class `Prepared`
Parameters:
  `alwaysQuote` - quote all identifiers
Returns:
  the execution plan

#### prepare

    public void prepare()

Description copied from class: `Prepared`
Prepare this statement.

Specified by:
  `prepare` in interface `DataChangeStatement`
Overrides:
  `prepare` in class `Prepared`

#### setSourceTableFilter

    public void setSourceTableFilter(TableFilter sourceTableFilter)

#### getSourceTableFilter

    public TableFilter getSourceTableFilter()

#### setOnCondition

    public void setOnCondition(Expression condition)

#### getOnCondition

    public Expression getOnCondition()

#### getWhen

    public java.util.ArrayList<MergeUsing.When> getWhen()

#### addWhen

    public void addWhen(MergeUsing.When w)

Adds WHEN command.

Parameters:
  `w` - new WHEN command to add (update, delete or insert).

#### setQueryAlias

    public void setQueryAlias(java.lang.String alias)

#### getQueryAlias

    public java.lang.String getQueryAlias()

#### getQuery

    public Query getQuery()

#### setQuery

    public void setQuery(Query query)

#### getTable

    public Table getTable()

Description copied from interface: `DataChangeStatement`
Return the target table.

Specified by:
  `getTable` in interface `DataChangeStatement`
Returns:
  the target table

#### setTargetTableFilter

    public void setTargetTableFilter(TableFilter targetTableFilter)

#### getTargetTableFilter

    public TableFilter getTargetTableFilter()

#### getTargetTable

    public Table getTargetTable()

#### setTargetTable

    public void setTargetTable(Table targetTable)

#### isTransactional

    public boolean isTransactional()

Description copied from class: `Prepared`
Check if this command is transactional. If it is not, then it forces the current transaction to commit.

Specified by:
  `isTransactional` in class `Prepared`
Returns:
  true if it is

#### queryMeta

    public ResultInterface queryMeta()

Description copied from class: `Prepared`
Get an empty result set containing the meta data.

Specified by:
  `queryMeta` in class `Prepared`
Returns:
  the result set

#### getType

    public int getType()

Description copied from class: `Prepared`
Get the command type as defined in CommandInterface

Specified by:
  `getType` in class `Prepared`
Returns:
  the statement type

#### getStatementName

    public java.lang.String getStatementName()

Description copied from interface: `DataChangeStatement`
Return the name of this statement.

Specified by:
  `getStatementName` in interface `DataChangeStatement`
Returns:
  the short name of this statement.

#### hasCombinedMatchedClause

    public boolean hasCombinedMatchedClause()

Whether any of the "when" parts contain both an update and a delete part.

Returns:
  the if one part does

#### collectDependencies

    public void collectDependencies(java.util.HashSet<DbObject> dependencies)

Description copied from class: `Prepared`
Find and collect all DbObjects, this Prepared depends on.

Overrides:
  `collectDependencies` in class `Prepared`
Parameters:
  `dependencies` - collection of dependencies to populate