Upsert Strategy Codes

## Variables

const | SqlUtil::AbstractTable::UpsertAuto = 4
| Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst. More...
const | SqlUtil::AbstractTable::UpsertInsertFirst = 1
| Upsert option: insert first, if the insert fails, then update. More...
const | SqlUtil::AbstractTable::UpsertInsertOnly = 5
| Upsert option: insert if the row does not exist, otherwise ignore. More...
const | SqlUtil::AbstractTable::UpsertSelectFirst = 3
| Upsert option: select first, if the row is unchanged, do nothing, if it doesn't exist, insert, otherwise update. More...
const | SqlUtil::AbstractTable::UpsertStrategyDescriptionMap
| hash mapping upsert strategy descriptions to upsert strategy codes More...
const | SqlUtil::AbstractTable::UpsertStrategyMap
| hash mapping upsert strategy codes to a text description More...
const | SqlUtil::AbstractTable::UpsertUpdateFirst = 2
| Upsert option: update first, if the update fails, then insert. More...
const | SqlUtil::AbstractTable::UpsertUpdateOnly = 6
| Upsert option: update if the row exists, otherwise ignore. More...

## Detailed Description

These options are used with:

- SqlUtil::AbstractTable::getBulkUpsertClosure()
- SqlUtil::AbstractTable::getUpsertClosure()
- SqlUtil::AbstractTable::getUpsertClosureWithValidation()
- SqlUtil::AbstractTable::upsert()
- SqlUtil::AbstractTable::upsertCommit()
- SqlUtil::AbstractTable::upsertFromIterator()
- SqlUtil::AbstractTable::upsertFromIteratorCommit()
- SqlUtil::AbstractTable::upsertFromSelect()
- SqlUtil::AbstractTable::upsertFromSelectCommit()

to specify the upsert strategy when synchronizing table data

## Variable Documentation

## UpsertAuto

const SqlUtil::AbstractTable::UpsertAuto = 4

Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst.

With this upsert strategy, the following row result codes are possible:

- UR_Inserted
- UR_Verified (the only value returned by certain drivers with optimized upsert implementations)

## UpsertInsertFirst

const SqlUtil::AbstractTable::UpsertInsertFirst = 1

Upsert option: insert first, if the insert fails, then update.

with this option an insert is attempted, and if it fails due to a duplicate row, then an update is made unconditionally; with this upsert strategy, the following row result codes are possible:

- UR_Inserted
- UR_Verified (the only value returned by certain drivers with optimized upsert implementations)

## UpsertInsertOnly

const SqlUtil::AbstractTable::UpsertInsertOnly = 5

Upsert option: insert if the row does not exist, otherwise ignore.

With this upsert strategy, the following row result codes are possible:

- UR_Inserted
- UR_Unchanged

## UpsertSelectFirst

const SqlUtil::AbstractTable::UpsertSelectFirst = 3

Upsert option: select first, if the row is unchanged, do nothing, if it doesn't exist, insert, otherwise update.

with this option the row is selected, if it doesn't exist, an insert is made, and an update is made only if the values are different; with this upsert strategy, the following row result codes are possible:

- UR_Inserted
- UR_Updated
- UR_Unchanged

## UpsertStrategyDescriptionMap

const SqlUtil::AbstractTable::UpsertStrategyDescriptionMap

Initial value:
= (
"UpsertInsertFirst": UpsertInsertFirst,
"UpsertUpdateFirst": UpsertUpdateFirst,
"UpsertSelectFirst": UpsertSelectFirst,
"UpsertAuto": UpsertAuto,
"UpsertInsertOnly": UpsertInsertOnly,
"UpsertUpdateOnly": UpsertUpdateOnly,
)

hash mapping upsert strategy descriptions to upsert strategy codes

See also
  UpsertStrategyMap for a reverse mapping

## UpsertStrategyMap

const SqlUtil::AbstractTable::UpsertStrategyMap

Initial value:
= (
UpsertInsertFirst: "UpsertInsertFirst",
UpsertUpdateFirst: "UpsertUpdateFirst",
UpsertSelectFirst: "UpsertSelectFirst",
UpsertAuto: "UpsertAuto",
UpsertInsertOnly: "UpsertInsertOnly",
UpsertUpdateOnly: "UpsertUpdateOnly",
)

hash mapping upsert strategy codes to a text description

See also
  UpsertStrategyDescriptionMap for a reverse mapping

## UpsertUpdateFirst

const SqlUtil::AbstractTable::UpsertUpdateFirst = 2

Upsert option: update first, if the update fails, then insert.

with this option an update is attempted, and if it fails due to a missing row, then an insert is performed; with this upsert strategy, the following row result codes are possible:

- UR_Inserted
- UR_Verified (the only value returned by certain drivers with optimized upsert implementations)

## UpsertUpdateOnly

const SqlUtil::AbstractTable::UpsertUpdateOnly = 6

Upsert option: update if the row exists, otherwise ignore.

With this upsert strategy, the following row result codes are possible:

- UR_Verified
- UR_Unchanged