Qore SqlUtil Module Reference: Upsert Strategy Codes

Qore SqlUtil Module Reference 1.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

All Classes Namespaces Functions Variables Groups Pages
Variables
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...

## Detailed Description

These options are used with:

- SqlUtil::AbstractTable::getUpsertClosure()
- SqlUtil::AbstractTable::getUpsertClosureWithValidation()
- SqlUtil::AbstractTable::upsert()
- SqlUtil::AbstractTable::upsertNoCommit()
- SqlUtil::AbstractTable::upsertFromIterator()
- SqlUtil::AbstractTable::upsertFromIteratorNoCommit()
- SqlUtil::AbstractTable::upsertFromSelect()
- SqlUtil::AbstractTable::upsertFromSelectNoCommit()

to specify the upsert strategy when synchronizing table data

## Variable Documentation

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

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

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

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

const SqlUtil::AbstractTable::UpsertStrategyDescriptionMap

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

hash mapping upsert strategy descriptions to upsert strategy codes

See Also
  UpsertStrategyMap for a reverse mapping

const SqlUtil::AbstractTable::UpsertStrategyMap

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

hash mapping upsert strategy codes to a text description

See Also
  UpsertStrategyDescriptionMap for a reverse mapping

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