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
-
public final class Merge extends CommandWithValues
This class represents the statement MERGE or the MySQL compatibility statement REPLACE
-
-
Field Summary
Fields Modifier and Type Field Description private Column[]columnsprivate booleanisReplaceprivate Column[]keysprivate Queryqueryprivate Tabletableprivate Updateupdate-
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 Constructor Description Merge(SessionLocal session, boolean isReplace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcollectDependencies(java.util.HashSet<DbObject> dependencies)Find and collect all DbObjects, this Prepared depends on.java.lang.StringgetPlanSQL(int sqlFlags)Get the SQL statement with the execution plan.java.lang.StringgetStatementName()Return the name of this statement.TablegetTable()Return the target table.intgetType()Get the command type as defined in CommandInterfaceprivate intmerge(Row row, Expression[] expressions, ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)Updates an existing row or inserts a new one.voidprepare()Prepare this statement.voidsetColumns(Column[] columns)voidsetCommand(Command command)Set the command.voidsetKeys(Column[] keys)voidsetQuery(Query query)voidsetTable(Table table)longupdate(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
-
-
-
-
Constructor Detail
-
Merge
public Merge(SessionLocal session, boolean isReplace)
-
-
Method Detail
-
setCommand
public void setCommand(Command command)
Description copied from class:PreparedSet the command.- Overrides:
setCommandin classPrepared- Parameters:
command- the new command
-
getTable
public Table getTable()
Description copied from class:DataChangeStatementReturn the target table.- Specified by:
getTablein classDataChangeStatement- Returns:
- the target table
-
setTable
public void setTable(Table table)
-
setColumns
public void setColumns(Column[] columns)
-
setKeys
public void setKeys(Column[] keys)
-
setQuery
public void setQuery(Query query)
-
update
public long update(ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)
Description copied from class:DataChangeStatementExecute the statement with specified delta change collector and collection mode.- Specified by:
updatein 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
public java.lang.String getPlanSQL(int sqlFlags)
Description copied from class:PreparedGet the SQL statement with the execution plan.- Overrides:
getPlanSQLin classPrepared- Parameters:
sqlFlags- formatting flags- Returns:
- the execution plan
-
prepare
public void prepare()
Description copied from class:PreparedPrepare this statement.
-
getType
public int getType()
Description copied from class:PreparedGet the command type as defined in CommandInterface
-
getStatementName
public java.lang.String getStatementName()
Description copied from class:DataChangeStatementReturn the name of this statement.- Specified by:
getStatementNamein classDataChangeStatement- Returns:
- the short name of this statement.
-
collectDependencies
public void collectDependencies(java.util.HashSet<DbObject> dependencies)
Description copied from class:PreparedFind and collect all DbObjects, this Prepared depends on.- Overrides:
collectDependenciesin classPrepared- Parameters:
dependencies- collection of dependencies to populate
-
-