org.h2.command.dml

## Class Insert

- java.lang.Object
- - org.h2.command.Prepared
  - - org.h2.command.dml.CommandWithValues
    - - org.h2.command.dml.Insert

All Implemented Interfaces:
  ResultTarget

    public class Insert
    extends CommandWithValues
    implements ResultTarget

This class represents the statement INSERT

### Field Summary

### Fields inherited from class org.h2.command.dml.CommandWithValues

`valuesExpressionList`

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

`create, parameters, prepareAlways, session, sqlStatement`

### Constructor Summary

Constructors
Constructor and Description
`Insert(Session session)`

### Method Summary

Methods
`void` `addAssignmentForDuplicate(Column column, Expression expression)` Keep a collection of the columns to pass to update if a duplicate key happens, for MySQL-style INSERT ...
`void` `addRow(Value[] values)` Add the row to the result set.
`java.lang.String` `getPlanSQL(boolean alwaysQuote)` Get the SQL statement with the execution plan.
`int` `getRowCount()` Get the number of rows.
`int` `getType()` Get the command type as defined in CommandInterface
`boolean` `isCacheable()`
`boolean` `isTransactional()` Check if this command is transactional.
`void` `limitsWereApplied()` A hint that sorting, offset and limit may be ignored by this result because they were applied during the query.
`void` `prepare()` Prepare this statement.
`ResultInterface` `queryMeta()` Get an empty result set containing the meta data.
`void` `setColumns(Column[] columns)`
`void` `setCommand(Command command)` Set the command.
`void` `setIgnore(boolean ignore)` Sets MySQL-style INSERT IGNORE mode
`void` `setInsertFromSelect(boolean value)`
`void` `setQuery(Query query)`
`void` `setSortedInsertMode(boolean sortedInsertMode)`
`void` `setSourceTableFilter(TableFilter sourceTableFilter)`
`void` `setTable(Table table)`
`int` `update()` Execute the statement.

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

`addRow`

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

`checkCanceled, checkParameters, getCteCleanups, getCurrentRowNumber, getObjectId, getParameters, getPersistedObjectId, getSession, getSimpleSQL, getSQL, getSQL, isQuery, isReadOnly, needRecompile, query, setCteCleanups, setCurrentRowNumber, setParameterList, setPersistedObjectId, setPrepareAlways, setRow, setSession, setSQL, toString`

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

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

### Constructor Detail

#### Insert

    public Insert(Session session)

### Method Detail

#### setCommand

    public void setCommand(Command command)

Description copied from class: `Prepared`
Set the command.

Overrides:
  `setCommand` in class `Prepared`
Parameters:
  `command` - the new command

#### setTable

    public void setTable(Table table)

#### setColumns

    public void setColumns(Column[] columns)

#### setIgnore

    public void setIgnore(boolean ignore)

Sets MySQL-style INSERT IGNORE mode

Parameters:
  `ignore` - ignore errors

#### setQuery

    public void setQuery(Query query)

#### addAssignmentForDuplicate

    public void addAssignmentForDuplicate(Column column,
                                 Expression expression)

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 column
  `expression` - the expression

#### update

    public int update()

Description copied from class: `Prepared`
Execute the statement.

Overrides:
  `update` in class `Prepared`
Returns:
  the update count

#### addRow

    public void addRow(Value[] values)

Description copied from interface: `ResultTarget`
Add the row to the result set.

Specified by:
  `addRow` in interface `ResultTarget`
Parameters:
  `values` - the values

#### getRowCount

    public int getRowCount()

Description copied from interface: `ResultTarget`
Get the number of rows.

Specified by:
  `getRowCount` in interface `ResultTarget`
Returns:
  the number of rows

#### limitsWereApplied

    public void limitsWereApplied()

Description copied from interface: `ResultTarget`
A 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:
  `limitsWereApplied` in interface `ResultTarget`

#### getPlanSQL

    public java.lang.String getPlanSQL(boolean alwaysQuote)

Description copied from class: `Prepared`
Get the SQL statement with the execution plan.

Overrides:
  `getPlanSQL` in class `Prepared`
Parameters:
  `alwaysQuote` - quote all identifiers
Returns:
  the execution plan

#### prepare

    public void prepare()

Description copied from class: `Prepared`
Prepare this statement.

Overrides:
  `prepare` in class `Prepared`

#### isTransactional

    public boolean isTransactional()

Description copied from class: `Prepared`
Check if this command is transactional. If it is not, then it forces the current transaction to commit.

Specified by:
  `isTransactional` in class `Prepared`
Returns:
  true if it is

#### queryMeta

    public ResultInterface queryMeta()

Description copied from class: `Prepared`
Get an empty result set containing the meta data.

Specified by:
  `queryMeta` in class `Prepared`
Returns:
  the result set

#### setSortedInsertMode

    public void setSortedInsertMode(boolean sortedInsertMode)

#### 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

#### setInsertFromSelect

    public void setInsertFromSelect(boolean value)

#### isCacheable

    public boolean isCacheable()

Overrides:
  `isCacheable` in class `Prepared`

#### setSourceTableFilter

    public void setSourceTableFilter(TableFilter sourceTableFilter)