275 "unstable_input":
sprintf(
"if this is set to True then a slower insert/upsert method will be used that verifies each input row; if False an optimized insert/upsert method is used (additionally bulk inserts/upserts are possible) but all input hashes must have the same keys in the same order; default: %y",
OptionDefaults.unstable_input),
276 "insert_block":
sprintf(
"the row block size used when bulk DML / batch inserts/upserts are used; default: %y",
OptionDefaults.insert_block),
277 "rowcode":
"a closure or call reference taking a single hash argument representing the row values inserted/upserted plus any output values generated in inserts (such as sequence values, for example)",
278 "upsert":
"if True then data will be upserted instead of inserted",
279 "upsert_strategy":
"the upsert strategy code to use; implies 'upsert'",
284 "unstable_input":
False,
285 "insert_block": 1000,
700 deprecated
static nothing
addBatchToBatch(reference<hash> hb, reference x1,
hash batch, *reference x2);
820 error2(
string ex,
string fmt);
1272 "select_block" :
sprintf(
"the row block size used when bulk DML / batch inserts are used; default: %y",
OptionDefaults.select_block),
1277 "select_block": 1000,
1284 SQLStatement m_stmt;
1389 "table":
"(required) the AbstractTable object for the source of the data",
1390 "sh":
"(optional) an SqlUtil select hash",
1467 AbstractDatasource m_ds;
1472 "datasource":
"(internal) the datasource containing the target table",
1473 "select":
"(internal) the SQL statement used",
1474 "bind":
"(internal) a runtime bind-variable (soft)list",
abstract Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
string getTableName()
returns the table name
commit()
commits the transaction and frees the Qore::SQL::AbstractDatasource transaction thread resource ...
int commitLimit()
returns the commit_limit value set in the constructor()
nothing commit()
commits the transaction
string sprintf(string fmt,...)
string getTableName()
returns the table name
hash getValue()
returns the current row transformed with the mapper
constructor(TableMapper::AbstractSqlStatementOutboundMapper mapper)
creates the iterator from the Mapper passed
provides a hash iterator based on a InboundTableMapper object and an iterator input source; for each ...
Definition: TableMapper.qm.dox.h:888
Qore::SQL::SQLStatement stmt
statement for inserts/upserts
Definition: TableMapper.qm.dox.h:310
int commit_limit
row commit limit (<= 0 for no commits)
Definition: TableMapper.qm.dox.h:900
hash< auto > optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
*list getReturning()
returns a list argument for the SqlUtil "returning" option, if applicable
initOptions(reference< hash > opts)
initializes options
Mapper::Mapper m_mapper
data mapper
Definition: TableMapper.qm.dox.h:1128
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
*int upsert_strategy
upsert strategy option
Definition: TableMapper.qm.dox.h:330
provides an outbound data mapper to a Table with SqlUtil select hash as a asource ...
Definition: TableMapper.qm.dox.h:1378
setRuntime(string key, auto value)
set the runtime option with "key" to value "value"
destructor()
throws an exception if there is data pending in the block cache
hash hbuf
buffer for bulk DML
Definition: TableMapper.qm.dox.h:316
SqlUtil::AbstractTable getTable()
returns the underlying SqlUtil::AbstractTable object
hash validKeys()
returns a list of valid field keys for this class (can be overridden in subclasses) ...
replaceRuntime(*hash runtime)
replaces runtime options
bool next()
Moves the current position of the input iterator to the next element; returns False if there are no m...
hash optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
static hash getStaticInputRecord(SqlUtil::AbstractTable table, *hash input)
returns a description of the input record based on the AbstractTable source
initStatement()
initializes the internal statement object
static nothing addBatchToBatch(reference< hash > hb, hash batch)
abstract initOptions(reference< hash > opts)
re-implement to initialize options
provides an outbound data mapper to a raw SQL statement
Definition: TableMapper.qm.dox.h:1463
hash< auto > optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
nothing rollback()
discards any queued data and rolls back the transaction
checkMapField(string k, reference< auto > fh)
perform per-field pre-processing on the passed map in the constructor
resetCount()
resets the internal record count
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
hash validTypes()
returns a list of valid field types for this class (can be overridden in subclasses) ...
hash val
a copy of the last hash value mapped
Definition: TableMapper.qm.dox.h:906
const OptionDefaults
default option values
Definition: TableMapper.qm.dox.h:1276
*hash flush()
flushes any remaining batched data to the database; this method should always be called before commit...
const OptionDefaults
default option values
Definition: TableMapper.qm.dox.h:283
*hash flushIntern(bool force_flush)
*hash queueData(hash< auto > rec, *hash< auto > crec)
inserts/upserts a row (or a set of rows, in case a hash of lists is passed) into the block buffer bas...
bool hasBulk()
returns True because this class supports bulk mode
replaceRuntime(*hash runtime)
replaces runtime options
bool has_returning
if the AbstractTable object supports the "returning" clause
Definition: TableMapper.qm.dox.h:298
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
const OptionKeys
option keys for this object
Definition: TableMapper.qm.dox.h:274
static *hash getStaticInputRecord(Qore::SQL::AbstractDatasource ds, string sql, *softlist args, *hash input)
returns a description of the input record based on Qore::SQL::SQLStatement::describe() ...
setRuntime(string key, auto value)
set the runtime option with "key" to value "value"
resetCount()
resets the internal record count
initStatement()
initializes the internal statement object
deprecated hash insertRowNoCommit(hash rec)
Plain alias to insertRow(). Obsolete. Do not use.
SqlUtil::AbstractTable getTable()
returns the underlying SqlUtil::AbstractTable object
*int getRecListSize(hash rec)
nothing rollback()
rolls back the transaction
*hash queueDataIntern(hash rec)
inserts a row into the block buffer based on a mapped input record; does not commit the transaction ...
bool upsert
upsert flag
Definition: TableMapper.qm.dox.h:327
init(hash mapv, *hash opts)
common constructor initialization
int getCount()
returns the internal record count
*code upsert_code
closure used for upserting
Definition: TableMapper.qm.dox.h:333
initOptions(reference< hash > opts)
initializes options
abstract initStatement()
re-implement to initialize Qore::SQL::SQLStatement on demand
int getCount()
returns the internal record count
nothing commit()
flushes any queued data and commits the transaction
hash record2Batch(hash h)
init(hash mapv, *hash opts)
common constructor initialization
int cnt
row count for commit
Definition: TableMapper.qm.dox.h:903
const OptionKeys
option keys for this object
Definition: TableMapper.qm.dox.h:1271
mapFieldType(string key, hash m, reference< auto > v, hash rec)
performs type handling
SqlUtil::AbstractDatabase db
the target Database object in case sequence value need to be acquired
Definition: TableMapper.qm.dox.h:295
bool unstable_input
"unstable input" option for non-optimized inserts/upserts (~33% performance reduction in insert/upser...
Definition: TableMapper.qm.dox.h:307
constructor(Qore::AbstractIterator i, InboundTableMapper mapper)
creates the iterator from the mapper passed
maps from source to target tables with exactly the same structure
Definition: TableMapper.qm.dox.h:826
hash getValue()
returns the current row transformed with the mapper
error(string fmt)
prepends the datasource description to the error string and calls Mapper::error() ...
the TableMapper namespace contains all the definitions in the TableMapper module
Definition: TableMapper.qm.dox.h:267
auto getRuntime(string key)
get current runtime option value for a key
provides an abstract base for all SQL based outbound mappers
Definition: TableMapper.qm.dox.h:1266
list mapBulk(int size)
performs bulk mapping by selecting the requested number of rows in a single select ...
*list getDataRows()
Retrieve mapped data as a list of hashes.
*hash getData()
Retrieve mapped data as a hash of lists.
error2(string ex, string fmt)
prepends the datasource description to the error description and calls Mapper::error2() ...
list ret_args
"returning" arguments for sequences
Definition: TableMapper.qm.dox.h:301
rollback()
rolls the transaction back and frees the Qore::SQL::AbstractDatasource transaction thread resource ...
provides a hash iterator based on a mapper object and an SQLStatement or SqlUtil select hash ...
Definition: TableMapper.qm.dox.h:1119
provides an inbound data mapper to a Table target
Definition: TableMapper.qm.dox.h:269
Qore::SQL::SQLStatement getRowIterator()
returns a row iterator for the underlying SQL statement for this object
SqlStatementMapperIterator iterator()
Returns an SqlStatementMapperIterator based on the current object.
discard()
discards any buffered batched data; this method should be called after using the batch APIs (queueDat...
hash insertRow(hash rec)
inserts or upserts a row into the target table based on a mapped input record; does not commit the tr...
string getTableName()
returns the table name
TableMapper::InboundTableMapper mapc
data mapper
Definition: TableMapper.qm.dox.h:897
list out_args
extra arguments for sequence output binds
Definition: TableMapper.qm.dox.h:304
hash< auto > optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
int insert_block
bulk DML block size (also valid for upserts despite the name)
Definition: TableMapper.qm.dox.h:313
static *hash getStaticInputRecord(AbstractTable table, *hash select_hash, *reference< string > sql, *hash input)
returns a description of the input record based on Qore::SQL::SQLStatement::describe() ...
const OptionKeys
option keys for this object
Definition: TableMapper.qm.dox.h:1388
SqlUtil::AbstractTable table
the target table object
Definition: TableMapper.qm.dox.h:292
auto getRuntime(string key)
get current runtime option value for a key
TableMapper::InboundTableMapperIterator iterator(Qore::AbstractIterator i)
returns an iterator for the current object
logOutput(hash h)
ignore logging from Mapper since we may have to log sequence values; output logged manually in insert...
*code rowcode
per-row Closures or Call References for batch inserts/upserts
Definition: TableMapper.qm.dox.h:324
setRowCode(*code rowc)
sets a closure or call reference that will be called when data has been sent to the database and all ...