218 "unstable_input":
sprintf(
"if this is set to True then a slower insert method will be used that verifies each input row; if False an optimized insert method is used (additionally bulk inserts are possible) but all input hashes must have the same keys in the same order; default: %y",
OptionDefaults.unstable_input),
219 "insert_block":
sprintf(
"the row block size used when bulk DML / batch inserts are used; default: %y",
OptionDefaults.insert_block),
220 "rowcode":
"a closure or call reference taking a single hash argument representing the row values inserted plus any output values generated in the insert (such as sequence values, for example)",
225 "unstable_input":
False,
226 "insert_block": 1000,
585 private error(
string fmt);
589 private error2(
string ex,
string fmt);
862 private setup(
hash mapv, *
hash opts);
901 "select_block" :
sprintf(
"the row block size used when bulk DML / batch inserts are used; default: %y",
OptionDefaults.select_block),
906 "select_block": 1000,
1065 AbstractDatasource m_ds;
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 AbstractDatasource resource
int commitLimit()
returns the commit_limit value set in the constructor()
nothing commit()
commits the transaction
static *hash getStaticInputRecord(AbstractDatasource ds, string sql, *softlist args)
returns a description of the input record based on Qore::SQL::SQLStatement::describe() ...
string sprintf(string fmt,...)
string getTableName()
returns the table name
hash getValue()
returns the current row transformed with the mapper
private init(hash mapv, *hash opts)
common constructor initialization
*hash queueData(hash rec, *hash crec)
inserts a row (or a set of rows, in case a hash of lists is passed) into the block buffer based on a ...
provides a hash iterator based on a InboundTableMapper object and an iterator input source; for each ...
Definition: TableMapper.qm.dox.h:653
int commit_limit
row commit limit (<= 0 for no commits)
Definition: TableMapper.qm.dox.h:665
private init(hash mapv, *hash opts)
common constructor initialization
private hash flushIntern()
flushes queued data to the database
*list getReturning()
returns a list argument for the SqlUtil "returning" option, if applicable
private error2(string ex, string fmt)
prepends the datasource description to the error description and calls Mapper::error2() ...
Mapper::Mapper m_mapper
data mapper
Definition: TableMapper.qm.dox.h:825
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
static *hash getStaticInputRecord(AbstractTable table, *hash select_hash, *reference sql)
returns a description of the input record based on Qore::SQL::SQLStatement::describe() ...
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
provides an outbound data mapper to a Table with SqlUtil select hash as a asource ...
Definition: TableMapper.qm.dox.h:991
destructor()
throws an exception if there is data pending in the block cache
hash hbuf
buffer for bulk inserts
Definition: TableMapper.qm.dox.h:257
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) ...
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) ...
initStatement()
initializes the internal statement object
static hash getStaticInputRecord(SqlUtil::AbstractTable table)
returns a description of the input record based on the AbstractTable source
provides an outbound data mapper to a raw SQL statement
Definition: TableMapper.qm.dox.h:1061
nothing rollback()
discards any queued data and rolls back the transaction
Mapper::MapperIterator iterator()
Get MapperIterator for easy line-by-line processing.
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:671
const OptionDefaults
default option values
Definition: TableMapper.qm.dox.h:905
*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:224
abstract private initStatement()
re-implement to initialize Qore::SQL::SQLStatement on demand
bool hasBulk()
returns True because this class supports bulk mode
private *hash queueDataIntern(hash rec)
inserts a row into the block buffer based on a mapped input record; does not commit the transaction ...
bool has_returning
if the AbstractTable object supports the "returning" clause
Definition: TableMapper.qm.dox.h:239
Qore::SQL::AbstractDatasource getDatasource()
returns the AbstractDatasource object associated with this object
const OptionKeys
option keys for this object
Definition: TableMapper.qm.dox.h:217
constructor(Qore::AbstractIterator i, SqlUtil::Table target, hash mapv, *hash opts, int commit_limit=0)
creates the iterator from the arguments passed
resetCount()
resets the internal record count
private checkMapField(string k, reference fh)
perform per-field pre-processing on the passed map in the constructor
deprecated hash insertRowNoCommit(hash rec)
Plain alias to insertRow(). Obsolete. Do not use.
private initOptions(reference opts)
initializes options
SqlUtil::AbstractTable getTable()
returns the underlying SqlUtil::AbstractTable object
nothing rollback()
rolls back the transaction
int getCount()
returns the internal record count
private error(string fmt)
prepends the datasource description to the error string and calls Mapper::error() ...
int getCount()
returns the internal record count
nothing commit()
flushes any queued data and commits the transaction
int cnt
row count for commit
Definition: TableMapper.qm.dox.h:668
const OptionKeys
option keys for this object
Definition: TableMapper.qm.dox.h:900
private initStatement()
initializes the internal statement object
SqlUtil::AbstractDatabase db
the target Database object in case sequence value need to be acquired
Definition: TableMapper.qm.dox.h:236
bool unstable_input
"unstable input" option for non-optimized inserts (~33% performance reduction in insert speed) ...
Definition: TableMapper.qm.dox.h:248
maps from source to target tables with exactly the same structure
Definition: TableMapper.qm.dox.h:594
hash getValue()
returns the current row transformed with the mapper
private initOptions(reference opts)
initializes options
the TableMapper namespace contains all the definitions in the TableMapper module
Definition: TableMapper.qm.dox.h:210
provides an abstract base for all SQL based outbound mappers
Definition: TableMapper.qm.dox.h:895
constructor(SqlUtil::AbstractTable table, hash sh, hash mapv, *hash opts)
creates the iterator from the arguments passed
list mapBulk(int size)
performs bulk mapping by selecting the requested number of rows in a single select ...
hash optionKeys()
returns a list of valid constructor options for this class (can be overridden in subclasses) ...
*list getDataRows()
Retrieve mapped data as a hash of lists.
*hash getData()
Retrieve mapped data as a hash of lists.
list ret_args
"returning" arguments for sequences
Definition: TableMapper.qm.dox.h:242
rollback()
rolls the transaction back and frees the AbstractDatasource resource
provides a hash iterator based on a mapper object and an SQLStatement or SqlUtil select hash ...
Definition: TableMapper.qm.dox.h:816
provides an inbound data mapper to a Table target
Definition: TableMapper.qm.dox.h:212
discard()
discards any buffered batched data; this method should be called after using the batch APIs (queueDat...
hash insertRow(hash rec)
inserts a row into the target table based on a mapped input record; does not commit the transaction ...
string getTableName()
returns the table name
TableMapper::InboundTableMapper mapc
data mapper
Definition: TableMapper.qm.dox.h:662
list out_args
extra arguments for sequence output binds
Definition: TableMapper.qm.dox.h:245
int insert_block
bulk insert block size
Definition: TableMapper.qm.dox.h:254
SQLStatement stmt
statement for inserts
Definition: TableMapper.qm.dox.h:251
abstract private initOptions(reference opts)
re-implement to initialize options
SqlUtil::AbstractTable table
the target table object
Definition: TableMapper.qm.dox.h:233
logOutput(hash h)
ignore logging from Mapper since we may have to log sequence values; output logged manually in insert...
private mapFieldType(string key, hash m, reference v, hash rec)
performs type handling
*code rowcode
per-row Closures or Call References for batch inserts
Definition: TableMapper.qm.dox.h:260
setRowCode(*code rowc)
sets a closure or call reference that will be called when data has been sent to the database and all ...