Package org.h2.command.dml
Class Insert
java.lang.Object
org.h2.command.Prepared
org.h2.command.dml.DataChangeStatement
org.h2.command.dml.CommandWithValues
org.h2.command.dml.Insert
- All Implemented Interfaces:
ResultTarget
This class represents the statement
INSERT
-
Field Summary
Fields inherited from class org.h2.command.dml.CommandWithValues
valuesExpressionListFields inherited from class org.h2.command.Prepared
create, parameters, prepareAlways, session, sqlStatement, sqlTokens -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAssignmentForDuplicate(Column column, Expression expression) Keep a collection of the columns to pass to update if a duplicate key happens, for MySQL-style INSERT ...voidAdd the row to the result set.voidcollectDependencies(HashSet<DbObject> dependencies) Find and collect all DbObjects, this Prepared depends on.getOnDuplicateKeyValue(int columnIndex) Get the value to use for the specified column in case of a duplicate key.getPlanSQL(StringBuilder builder, int sqlFlags) Appends the SQL statement with the execution plan.longGet the number of rows.Return the name of this statement.getTable()Return the target table.intgetType()Get the command type as defined in CommandInterfacebooleanvoidA hint that sorting, offset and limit may be ignored by this result because they were applied during the query.voidsetColumns(Column[] columns) voidsetCommand(Command command) Set the command.voidsetIgnore(boolean ignore) Sets MySQL-style INSERT IGNORE mode or PostgreSQL-style ON CONFLICT DO NOTHING.voidsetInsertFromSelect(boolean value) voidsetOverridingSystem(Boolean overridingSystem) voidvoidlongupdate(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
addRowMethods inherited from class org.h2.command.dml.DataChangeStatement
isTransactional, lockAndRecheckCondition, prepare, queryMeta, updateMethods 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, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, setWithParamValues, toString
-
Constructor Details
-
Insert
-
-
Method Details
-
setCommand
Description copied from class:PreparedSet the command.- Overrides:
setCommandin classPrepared- Parameters:
command- the new command
-
getTable
Description copied from class:DataChangeStatementReturn the target table.- Specified by:
getTablein classDataChangeStatement- Returns:
- the target table
-
setTable
-
setColumns
-
setIgnore
public void setIgnore(boolean ignore) Sets MySQL-style INSERT IGNORE mode or PostgreSQL-style ON CONFLICT DO NOTHING.- Parameters:
ignore- ignore duplicates
-
setQuery
-
setOverridingSystem
-
addAssignmentForDuplicate
Keep a collection of the columns to pass to update if a duplicate key happens, for MySQL-style INSERT ... ON DUPLICATE KEY UPDATE ....- Parameters:
column- the columnexpression- the expression
-
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
-
addRow
Description copied from interface:ResultTargetAdd the row to the result set.- Specified by:
addRowin interfaceResultTarget- Parameters:
values- the values
-
getRowCount
public long getRowCount()Description copied from interface:ResultTargetGet the number of rows.- Specified by:
getRowCountin interfaceResultTarget- Returns:
- the number of rows
-
limitsWereApplied
public void limitsWereApplied()Description copied from interface:ResultTargetA hint that sorting, offset and limit may be ignored by this result because they were applied during the query. This is useful for WITH TIES clause because result may contain tied rows above limit.- Specified by:
limitsWereAppliedin interfaceResultTarget
-
getPlanSQL
Description copied from class:PreparedAppends the SQL statement with the execution plan.- Overrides:
getPlanSQLin classPrepared- Parameters:
builder- string buildersqlFlags- formatting flags- Returns:
- the execution plan
-
getType
public int getType()Description copied from class:PreparedGet the command type as defined in CommandInterface -
getStatementName
Description copied from class:DataChangeStatementReturn the name of this statement.- Specified by:
getStatementNamein classDataChangeStatement- Returns:
- the short name of this statement.
-
setInsertFromSelect
public void setInsertFromSelect(boolean value) -
isCacheable
public boolean isCacheable()- Overrides:
isCacheablein classDataChangeStatement
-
getOnDuplicateKeyValue
Get the value to use for the specified column in case of a duplicate key.- Parameters:
columnIndex- the column index- Returns:
- the value
-
collectDependencies
Description copied from class:PreparedFind and collect all DbObjects, this Prepared depends on.- Overrides:
collectDependenciesin classPrepared- Parameters:
dependencies- collection of dependencies to populate
-