Loading...
Searching...
No Matches
SqlUtil::Table Class Reference

represents a database table; this class embeds an AbstractTable object that is created automatically in the constructor based on the database driver for the AbstractDatasource object providing the database connection More...

`#include <Table.qc.dox.h>`

## Public Member Functions

| constructor (AbstractDatasource ds, hash< auto > desc, string name, *hash< auto > opts)
| creates the object from a table description hash
| constructor (AbstractDatasource ds, string name, *hash< auto > opts)
| creates the Table object
| constructor (hash< auto > ds, string name, *hash< auto > opts)
| creates the Table object
| constructor (string ds, string name, *hash< auto > opts)
| creates the Table object
AbstractTable | getTable ()
| returns the AbstractTable object contained by this object
auto | methodGate (string meth)
| executes a method on the contained AbstractTable object

## Protected Attributes

AbstractTable | t
| the embedded AbstractTable object that actually provides the functionality for this class

## Detailed Description

represents a database table; this class embeds an AbstractTable object that is created automatically in the constructor based on the database driver for the AbstractDatasource object providing the database connection

Driver-specific modules that provide the AbstractTable implementation embedded in this class are loaded on demand based on the driver's name. The driver-specific module's name is generated based on the db-driver's name with the first letter capitalized then with `"SqlUtil"` appended.

Note
  SqlUtil::Table does not provide any functionality except it is able to create real low level AbstractTable inherited object. All functionality is provided by embedded AbstractTable object.

For example:

- `"oracle"`: OracleSqlUtil
- `"pgsql"`: PgsqlSqlUtil
- `"mysql"`: MysqlSqlUtil

etc.

Note
  Objects of Table class can hold AbstractTable pointing to a view in Oracle.

## Member Function Documentation

## constructor() [1/4]

SqlUtil::Table::constructor | ( | AbstractDatasource | ds,
|  | hash< auto > | desc,
|  | string | name,
|  | *hash< auto > | opts )

creates the object from a table description hash

Parameters

  ds | the AbstractDatasource for the connection to the database
  desc | a table description hash describing the table
  name | the name of the table
  opts | an optional hash of options for the table creation string; see SqlUtil::AbstractTable::TableOptions for common options; each driver can support additional driver-specific options

Exceptions

  OPTION-ERROR | invalid or unsupported option passed
  DESCRIPTION-ERROR | invalid or unsupported description hash value passed

## constructor() [2/4]

SqlUtil::Table::constructor | ( | AbstractDatasource | ds,
|  | string | name,
|  | *hash< auto > | opts )

creates the Table object

Example:
  Table table(ds, "table");

Parameters

  ds | the AbstractDatasource object used to provide the DB connection
  name | the name of the table
  opts | a hash of options for the table creation string; see SqlUtil::AbstractTable::TableOptions for common options; each driver can support additional driver-specific options

Exceptions

  TABLE-DRIVER-ERROR | no database-specific module can be loaded
  OPTION-ERROR | invalid or unsupported option passed

## constructor() [3/4]

SqlUtil::Table::constructor | ( | hash< auto > | ds,
|  | string | name,
|  | *hash< auto > | opts )

creates the Table object

Example:
  Table table("pgsql:user/pass@db%host", "table");

Parameters

  ds

  a hash giving parameters for the new datasource with the following possible keys (the `"type"` key is mandatory, also usable with the output of the parse_datasource() function):
  - `type:` (*string) The name of the database driver to use; this key is mandatory; if not present, an exception will be raised. See sql_constants for builtin constants for DBI drivers shipped with Qore, or see the DBI driver documentation to use an add-on driver (this string should be the name of the driver to be loaded)
  - `user:` (*string) The user name for the new connection
  - `pass:` (*string) The password for the new connection
  - `db:` (*string) The database name for the new connection
  - `charset:` (*string) The database-specific name of the character encoding to use for the new connection. Also see Qore::SQL::Datasource::setDBCharset() for a method that allows this parameter to be set after the constructor. If no value is passed for this parameter, then the database character encoding corresponding to the default character encoding for the Qore process will be used instead.
  - `host:` (*string) The host name for the new connection
  - `port:` (softint) The port number for the new connection
  - `options:` (*hash) Any options for the new connection

  name | the name of the table
  opts | a hash of options for the table creation string; see SqlUtil::AbstractTable::TableOptions for common options; each driver can support additional driver-specific options

Exceptions

  TABLE-DRIVER-ERROR | no database-specific module can be loaded
  OPTION-ERROR | invalid or unsupported option passed

## constructor() [4/4]

SqlUtil::Table::constructor | ( | string | ds,
|  | string | name,
|  | *hash< auto > | opts )

creates the Table object

Example:
  Table table("pgsql:user/pass@db%host", "table");

Parameters

  ds | a datasource description string in the format that can be parsed by parse_datasource()
  name | the name of the table
  opts | a hash of options for the table creation string; see SqlUtil::AbstractTable::TableOptions for common options; each driver can support additional driver-specific options

Exceptions

  TABLE-DRIVER-ERROR | no database-specific module can be loaded
  OPTION-ERROR | invalid or unsupported option passed

## methodGate()

auto SqlUtil::Table::methodGate | ( | string | meth | ) |

executes a method on the contained AbstractTable object

See SqlUtil::AbstractTable API for reference