Package org.h2.command.dml

# Class MergeUsing

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

public final class MergeUsing extends 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
Modifier and Type
Class
Description
`class`
`MergeUsing.When`
Abstract WHEN command of the MERGE statement.
`final class`
`MergeUsing.WhenMatchedThenDelete`
`final class`
`MergeUsing.WhenMatchedThenUpdate`
`final class`
`MergeUsing.WhenNotMatched`

## Field Summary

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

`create, parameters, prepareAlways, session, sqlStatement, sqlTokens`

## Constructor Summary

Constructors
Constructor
Description
`MergeUsing(SessionLocal session, TableFilter targetTableFilter)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addWhen(MergeUsing.When w)`
Adds WHEN command.
`void`
`collectDependencies(HashSet<DbObject> dependencies)`
Find and collect all DbObjects, this Prepared depends on.
`Expression`
`getOnCondition()`
`StringBuilder`
`getPlanSQL(StringBuilder builder, int sqlFlags)`
Appends the SQL statement with the execution plan.
`TableFilter`
`getSourceTableFilter()`
`String`
`getStatementName()`
Return the name of this statement.
`Table`
`getTable()`
Return the target table.
`TableFilter`
`getTargetTableFilter()`
`int`
`getType()`
Get the command type as defined in CommandInterface
`ArrayList<MergeUsing.When>`
`getWhen()`
`void`
`setOnCondition(Expression condition)`
`void`
`setSourceTableFilter(TableFilter sourceTableFilter)`
`void`
`setTargetTableFilter(TableFilter targetTableFilter)`
`long`
`update(ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)`
Execute the statement with specified delta change collector and collection mode.

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

`isCacheable, isTransactional, lockAndRecheckCondition, prepare, queryMeta, update`

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

`checkCanceled, checkParameters, getCurrentRowNumber, getDatabase, getObjectId, getParameters, getPersistedObjectId, getPlanSQL, getSession, getSimpleSQL, getSQL, getSQLTokens, invalidateCachedResult, isQuery, isReadOnly, isRetryable, isWithParamValues, needRecompile, query, setCommand, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, setWithParamValues, toString`

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

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

## Constructor Details

### MergeUsing

public MergeUsing(SessionLocal session, TableFilter targetTableFilter)

## Method Details

### update

public long update(ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)
Description copied from class: `DataChangeStatement`
Execute the statement with specified delta change collector and collection mode.

Specified by:
  `update` in class `DataChangeStatement`
Parameters:
  `deltaChangeCollector` - target result
  `deltaChangeCollectionMode` - collection mode
Returns:
  the update count

### getPlanSQL

public StringBuilder getPlanSQL(StringBuilder builder, int sqlFlags)
Description copied from class: `Prepared`
Appends the SQL statement with the execution plan.

Overrides:
  `getPlanSQL` in class `Prepared`
Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
Returns:
  the execution plan

### setSourceTableFilter

public void setSourceTableFilter(TableFilter sourceTableFilter)

### getSourceTableFilter

public TableFilter getSourceTableFilter()

### setOnCondition

public void setOnCondition(Expression condition)

### getOnCondition

public Expression getOnCondition()

### getWhen

public 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).

### getTable

public Table getTable()
Description copied from class: `DataChangeStatement`
Return the target table.

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

### setTargetTableFilter

public void setTargetTableFilter(TableFilter targetTableFilter)

### getTargetTableFilter

public TableFilter getTargetTableFilter()

### 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 String getStatementName()
Description copied from class: `DataChangeStatement`
Return the name of this statement.

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

### collectDependencies

public void collectDependencies(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