Loading...
Searching...
No Matches
TableMapper::AbstractSqlStatementOutboundMapper Class Reference

provides an abstract base for all SQL based outbound mappers More...

Inheritance diagram for TableMapper::AbstractSqlStatementOutboundMapper:
[legend]

## Public Member Functions

| commit ()
| commits the transaction and frees the Qore::SQL::AbstractDatasource transaction thread resource
| constructor (hash< auto > mapv, *hash< auto > opts)
| builds the object based on an optional hash providing field mappings, data constraints, and optionally custom mapping logic
*hash< string, auto > | getData ()
| Retrieve mapped data as a hash of lists.
*list< auto > | getDataRows ()
| Retrieve mapped data as a list of hashes.
abstract Qore::SQL::AbstractDatasource | getDatasource ()
| returns the AbstractDatasource object associated with this object
Qore::SQL::SQLStatement | getRowIterator ()
| returns a row iterator for the underlying SQL statement for this object
Qore::SQL::AbstractSQLStatement | getStatement ()
| returns a row iterator for the underlying SQL statement for this object
hash< string, hash< MapperOptionInfo > > | getUserOptions ()
| returns mapper options useful for users
SqlStatementMapperIterator | iterator ()
| Returns an SqlStatementMapperIterator based on the current object.
hash< auto > | optionKeys ()
| returns a list of valid constructor options for this class (can be overridden in subclasses)
| rollback ()
| rolls the transaction back and frees the Qore::SQL::AbstractDatasource transaction thread resource

## Public Attributes

const | OptionDefaults = ...
| default option values
const | OptionKeys = ...
| option keys for this class

## Protected Member Functions

abstract | initOptions (reference< hash > opts)
| re-implement to initialize options
abstract | initStatement ()
| re-implement to initialize Qore::SQL::AbstractSQLStatement on demand

## Static Protected Member Functions

static *hash< string, AbstractDataField > | getInputRecordFromStmt (AbstractSQLStatement stmt, *hash< auto > input)
| returns an input record description from an SQLStatement

## Detailed Description

provides an abstract base for all SQL based outbound mappers

## Member Function Documentation

## constructor()

TableMapper::AbstractSqlStatementOutboundMapper::constructor | ( | hash< auto > | mapv,
|  | *hash< auto > | opts )

builds the object based on an optional hash providing field mappings, data constraints, and optionally custom mapping logic

The source statement is also scanned using Qore::SQL::AbstractSQLStatement and column definitions are used to update the source record specification.

Parameters

  mapv | a optional hash providing overrides for the default 1:1 input to output field mappings; each hash key is the name in lower case of the output column in the target table; each value is either True (meaning no translations are done; the data is copied 1:1) or a hash describing the mapping; see mapperkeys for detailed documentation for this option

  opts

  a hash of options for the mapper; see mapperoptions for a description of valid mapper options plus the following options specific to this object:
  - `"select_block"`: for size of the batch returned from TableMapper::SqlStatementOutboundMapper::getData() or SqlStatementOutboundMapper::getDataRows()
  - `"sh"`: an SqlUtil select hash
  - `"table"`: (required) the AbstractTable object for the source of the data

Exceptions

  MAP-ERROR | invalid select_block size; must be >= 1 if present

## getData()

*hash< string, auto > TableMapper::AbstractSqlStatementOutboundMapper::getData | ( |  | ) |

Retrieve mapped data as a hash of lists.

Returns
  *hash with data or Qore::NOTHING in case there are no more data available.

The size of the batch is driven by the `select_block` option passed in the constructor.

The hash is in Qore::SQL::AbstractDatasource::select() form - meaning it is a hash with column names as keys. Values are lists of column values. This data structure is used for Qore::context statement or BulksSqlUtil operations.

## getDataRows()

*list< auto > TableMapper::AbstractSqlStatementOutboundMapper::getDataRows | ( |  | ) |

Retrieve mapped data as a list of hashes.

Returns
  *list with data or Qore::NOTHING in case there are no more data available.

Size of the batch is driven by the `select_block` option passed in the constructor.

List is in Qore::SQL::AbstractDatasource::selectRows() form - meaning it is a list with hashes, where every hash has column names as keys with single values as hash values.

## getRowIterator()

Qore::SQL::SQLStatement TableMapper::AbstractSqlStatementOutboundMapper::getRowIterator | ( |  | ) |

returns a row iterator for the underlying SQL statement for this object

Since
  TableMapper 1.1.1

Deprecated
  for getStatement(); if the underlying database connection object returns an AbstractSQLStatement instead of an SQLStatement, then an exception will be raised; use getStatement() instead

## getStatement()

Qore::SQL::AbstractSQLStatement TableMapper::AbstractSqlStatementOutboundMapper::getStatement | ( |  | ) |

returns a row iterator for the underlying SQL statement for this object

Since
  TableMapper 1.3

## iterator()

SqlStatementMapperIterator TableMapper::AbstractSqlStatementOutboundMapper::iterator | ( |  | ) |

Returns an SqlStatementMapperIterator based on the current object.

Returns
  an SqlStatementMapperIterator based on the current object

Data are retrieved with standard Qore::AbstractIterator::getValue() or similar. Value is a hash with column names as keys.

## optionKeys()

hash< auto > TableMapper::AbstractSqlStatementOutboundMapper::optionKeys | ( |  | ) |

returns a list of valid constructor options for this class (can be overridden in subclasses)

Returns
  a list of valid constructor options for this class (can be overridden in subclasses)