Top Description Fields Constructors Methods
org.h2.command.dml

public final Class Merge

extends CommandWithValues
Class Inheritance
Imports
java.util.ArrayList, .HashSet, org.h2.api.ErrorCode, .Trigger, org.h2.command.Command, .CommandInterface, org.h2.command.query.Query, org.h2.engine.DbObject, .Right, .SessionLocal, org.h2.expression.Expression, .Parameter, .ValueExpression, org.h2.index.Index, org.h2.message.DbException, org.h2.mvstore.db.MVPrimaryIndex, org.h2.result.ResultInterface, .ResultTarget, .Row, org.h2.table.Column, .DataChangeDeltaTable, .DataChangeDeltaTable.ResultOption, .Table, org.h2.util.HasSQL, org.h2.value.DataType, .TypeInfo, .Value, .ValueNull

This class represents the statement MERGE or the MySQL compatibility statement REPLACE

Field Summary

Modifier and TypeField and Description
private Column[]
private boolean
private Column[]
private Query
private Table
private Update
Inherited from org.h2.command.dml.CommandWithValues:
valuesExpressionList

Constructor Summary

AccessConstructor and Description
public
Merge(SessionLocal session, boolean isReplace)

Method Summary

Modifier and TypeMethod and Description
public void
collectDependencies(HashSet<DbObject>
collection of dependencies to populate
dependencies
)

Overrides org.h2.command.Prepared.collectDependencies.

Find and collect all DbObjects, this Prepared depends on.

pack-priv void
public StringBuilder
getPlanSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Overrides org.h2.command.Prepared.getPlanSQL.

Appends the SQL statement with the execution plan.

public String
getStatementName()

Implements abstract org.h2.command.dml.DataChangeStatement.getStatementName.

Return the name of this statement.

public Table
getTable()

Implements abstract org.h2.command.dml.DataChangeStatement.getTable.

Return the target table.

public int
getType()

Implements abstract org.h2.command.Prepared.getType.

Get the command type as defined in CommandInterface

private int

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
merge
(Row
row to replace
row
,
Expression[]
source expressions, or null
expressions
,
ResultTarget
target result
deltaChangeCollector
,
DataChangeDeltaTable.ResultOption
collection mode
deltaChangeCollectionMode
)

Updates an existing row or inserts a new one.

public void
setColumns(Column[] columns)

public void
setCommand(Command
the new command
command
)

Overrides org.h2.command.Prepared.setCommand.

Set the command.

public void
setKeys(Column[] keys)

public void
setQuery(Query query)

public void
setTable(Table table)

public long
update(ResultTarget
target result
deltaChangeCollector
,
DataChangeDeltaTable.ResultOption
collection mode
deltaChangeCollectionMode
)

Implements abstract org.h2.command.dml.DataChangeStatement.update.

Execute the statement with specified delta change collector and collection mode.

Inherited from org.h2.command.dml.CommandWithValues:
addRow

Field Detail

columnsback to summary
private Column[] columns
isReplaceback to summary
private boolean isReplace
keysback to summary
private Column[] keys
queryback to summary
private Query query
tableback to summary
private Table table
updateback to summary
private Update update

Constructor Detail

Mergeback to summary
public Merge(SessionLocal session, boolean isReplace)

Method Detail

collectDependenciesback to summary
public void collectDependencies(HashSet<DbObject> dependencies)

Overrides org.h2.command.Prepared.collectDependencies.

Doc from org.h2.command.Prepared.collectDependencies.

Find and collect all DbObjects, this Prepared depends on.

Parameters
dependencies:HashSet<DbObject>

collection of dependencies to populate

Annotations
@Override
doPrepareback to summary
pack-priv void doPrepare()

Implements abstract org.h2.command.dml.DataChangeStatement.doPrepare.

Annotations
@Override
getPlanSQLback to summary
public StringBuilder getPlanSQL(StringBuilder builder, int sqlFlags)

Overrides org.h2.command.Prepared.getPlanSQL.

Doc from org.h2.command.Prepared.getPlanSQL.

Appends the SQL statement with the execution plan.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the execution plan

Annotations
@Override
getStatementNameback to summary
public String getStatementName()

Implements abstract org.h2.command.dml.DataChangeStatement.getStatementName.

Doc from org.h2.command.dml.DataChangeStatement.getStatementName.

Return the name of this statement.

Returns:String

the short name of this statement.

Annotations
@Override
getTableback to summary
public Table getTable()

Implements abstract org.h2.command.dml.DataChangeStatement.getTable.

Doc from org.h2.command.dml.DataChangeStatement.getTable.

Return the target table.

Returns:Table

the target table

Annotations
@Override
getTypeback to summary
public int getType()

Implements abstract org.h2.command.Prepared.getType.

Doc from org.h2.command.Prepared.getType.

Get the command type as defined in CommandInterface

Returns:int

the statement type

Annotations
@Override
mergeback to summary
private int merge(Row row, Expression[] expressions, ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)

Updates an existing row or inserts a new one.

Parameters
row:Row

row to replace

expressions:Expression[]

source expressions, or null

deltaChangeCollector:ResultTarget

target result

deltaChangeCollectionMode:DataChangeDeltaTable.ResultOption

collection mode

Returns:int

1 if row was inserted, 1 if row was updated by a MERGE statement, and 2 if row was updated by a REPLACE statement

setColumnsback to summary
public void setColumns(Column[] columns)
setCommandback to summary
public void setCommand(Command command)

Overrides org.h2.command.Prepared.setCommand.

Doc from org.h2.command.Prepared.setCommand.

Set the command.

Parameters
command:Command

the new command

Annotations
@Override
setKeysback to summary
public void setKeys(Column[] keys)
setQueryback to summary
public void setQuery(Query query)
setTableback to summary
public void setTable(Table table)
updateback to summary
public long update(ResultTarget deltaChangeCollector, DataChangeDeltaTable.ResultOption deltaChangeCollectionMode)

Implements abstract org.h2.command.dml.DataChangeStatement.update.

Doc from org.h2.command.dml.DataChangeStatement.update.

Execute the statement with specified delta change collector and collection mode.

Parameters
deltaChangeCollector:ResultTarget

target result

deltaChangeCollectionMode:DataChangeDeltaTable.ResultOption

collection mode

Returns:long

the update count

Annotations
@Override