Package org.h2.command.dml
Class Merge
java.lang.Object
org.h2.command.Prepared
org.h2.command.dml.DataChangeStatement
org.h2.command.dml.CommandWithValues
org.h2.command.dml.Merge
This class represents the statement
MERGE
or the MySQL compatibility statement
REPLACE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Column[]
private boolean
private Column[]
private Query
private Table
private Update
Fields inherited from class org.h2.command.dml.CommandWithValues
valuesExpressionList
Fields inherited from class org.h2.command.Prepared
create, parameters, prepareAlways, session, sqlStatement, sqlTokens
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
collectDependencies
(HashSet<DbObject> dependencies) Find and collect all DbObjects, this Prepared depends on.getPlanSQL
(int sqlFlags) Get the SQL statement with the execution plan.Return the name of this statement.getTable()
Return the target table.int
getType()
Get the command type as defined in CommandInterfaceprivate int
merge
(Row row, Expression[] expressions, ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode) Updates an existing row or inserts a new one.void
prepare()
Prepare this statement.void
setColumns
(Column[] columns) void
setCommand
(Command command) Set the command.void
void
void
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.CommandWithValues
addRow
Methods inherited from class org.h2.command.dml.DataChangeStatement
isCacheable, isTransactional, queryMeta, update
Methods inherited from class org.h2.command.Prepared
checkCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getSession, getSimpleSQL, getSQL, getSQLTokens, isQuery, isReadOnly, needRecompile, query, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString
-
Field Details
-
isReplace
private boolean isReplace -
table
-
columns
-
keys
-
query
-
update
-
-
Constructor Details
-
Merge
-
-
Method Details
-
setCommand
Description copied from class:Prepared
Set the command.- Overrides:
setCommand
in classPrepared
- Parameters:
command
- the new command
-
getTable
Description copied from class:DataChangeStatement
Return the target table.- Specified by:
getTable
in classDataChangeStatement
- Returns:
- the target table
-
setTable
-
setColumns
-
setKeys
-
setQuery
-
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 classDataChangeStatement
- Parameters:
deltaChangeCollector
- target resultdeltaChangeCollectionMode
- collection mode- Returns:
- the update count
-
merge
private int merge(Row row, Expression[] expressions, ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode) Updates an existing row or inserts a new one.- Parameters:
row
- row to replaceexpressions
- source expressions, or nulldeltaChangeCollector
- target resultdeltaChangeCollectionMode
- collection mode- Returns:
- 1 if row was inserted, 1 if row was updated by a MERGE statement, and 2 if row was updated by a REPLACE statement
-
getPlanSQL
Description copied from class:Prepared
Get the SQL statement with the execution plan.- Overrides:
getPlanSQL
in classPrepared
- Parameters:
sqlFlags
- formatting flags- Returns:
- the execution plan
-
prepare
public void prepare()Description copied from class:Prepared
Prepare this statement. -
getType
public int getType()Description copied from class:Prepared
Get the command type as defined in CommandInterface -
getStatementName
Description copied from class:DataChangeStatement
Return the name of this statement.- Specified by:
getStatementName
in classDataChangeStatement
- Returns:
- the short name of this statement.
-
collectDependencies
Description copied from class:Prepared
Find and collect all DbObjects, this Prepared depends on.- Overrides:
collectDependencies
in classPrepared
- Parameters:
dependencies
- collection of dependencies to populate
-