Class Insert

    • Field Detail

      • table

        private Table table
      • columns

        private Column[] columns
      • query

        private Query query
      • rowNumber

        private long rowNumber
      • insertFromSelect

        private boolean insertFromSelect
      • overridingSystem

        private java.lang.Boolean overridingSystem
      • duplicateKeyAssignmentMap

        private java.util.HashMap<Column,​Expression> duplicateKeyAssignmentMap
        For MySQL-style INSERT ... ON DUPLICATE KEY UPDATE ....
      • onDuplicateKeyRow

        private Value[] onDuplicateKeyRow
      • ignore

        private boolean ignore
        For MySQL-style INSERT IGNORE and PostgreSQL-style ON CONFLICT DO NOTHING.
      • deltaChangeCollector

        private ResultTarget deltaChangeCollector
    • 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 or PostgreSQL-style ON CONFLICT DO NOTHING.
        Parameters:
        ignore - ignore duplicates
      • setQuery

        public void setQuery​(Query query)
      • setOverridingSystem

        public void setOverridingSystem​(java.lang.Boolean overridingSystem)
      • 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
      • insertRows

        private long insertRows()
      • 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 long 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​(int sqlFlags)
        Description copied from class: Prepared
        Get the SQL statement with the execution plan.
        Overrides:
        getPlanSQL in class Prepared
        Parameters:
        sqlFlags - formatting flags
        Returns:
        the execution plan
      • prepare

        public void prepare()
        Description copied from class: Prepared
        Prepare this statement.
        Overrides:
        prepare in class Prepared
      • 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)
      • handleOnDuplicate

        private boolean handleOnDuplicate​(DbException de,
                                          Value[] currentRow)
        Parameters:
        de - duplicate key exception
        currentRow - current row values (optional)
        Returns:
        true if row was updated, false if row was ignored
      • getOnDuplicateKeyValue

        public Value getOnDuplicateKeyValue​(int columnIndex)
        Get the value to use for the specified column in case of a duplicate key.
        Parameters:
        columnIndex - the column index
        Returns:
        the value
      • collectDependencies

        public void collectDependencies​(java.util.HashSet<DbObject> dependencies)
        Description copied from class: Prepared
        Find and collect all DbObjects, this Prepared depends on.
        Overrides:
        collectDependencies in class Prepared
        Parameters:
        dependencies - collection of dependencies to populate