Qore SqlUtil Module Reference
1.1
|
the base abstract class for the table implementation More...
Public Member Functions | |
AbstractCheckConstraint | addCheckConstraint (string cname, string src, *hash opt, *reference sql) |
adds a check constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractColumn | addColumn (string cname, hash opt, bool nullable=True, *reference lsql) |
adds a column to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractForeignConstraint | addForeignConstraint (string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql) |
adds a foreign constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractIndex | addIndex (string iname, bool unique, softlist cols, *hash opt, *reference sql) |
adds an index to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractPrimaryKey | addPrimaryKey (string pkname, softlist cols, *hash opt, *reference sql) |
adds a primary key to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractTrigger | addTrigger (string tname, string src, *hash opt, *reference lsql) |
adds a trigger to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
AbstractUniqueConstraint | addUniqueConstraint (string cname, softlist cols, *hash opt, *reference sql) |
adds a unique constraint to the table; if the table is known to be in the database already, then the constraint is added to the database also immediately; otherwise it is only added internally and can be created when create() is called for example More... | |
cache (*hash opts) | |
reads in all attributes of the table from the database More... | |
bool | checkExistence () |
returns True if the table exists in the database, False if not | |
abstract private bool | checkExistenceImpl () |
returns True if the table exists in the DB, False if not More... | |
clear () | |
purges the current table definition More... | |
private | clearImpl () |
clears any driver-specific table information | |
commit () | |
commits the current transaction on the underlying Qore::SQL::AbstractDatasource | |
abstract private bool | constraintsLinkedToIndexesImpl () |
returns True if the database links constraints to indexes (ie dropping the constraint drops the index, etc) | |
private | constructor (AbstractDatasource nds, string nname, *hash nopts) |
creates the object; private constructor More... | |
copy (AbstractTable old) | |
copies the object | |
abstract private | copyImpl (AbstractTable old) |
db-specific copy actions | |
create (*hash opt) | |
creates the table in the database; releases the transaction lock after creating the table More... | |
createNoCommit (*hash opt) | |
creates the table with all associated properties (indexes, constraints, etc) without any transaction management More... | |
int | del (*hash cond, *reference sql) |
deletes rows in the table matching the condition and returns the count of rows deleted; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
int | del (*hash cond, *hash opt) |
deletes rows in the table matching the condition and returns the count of rows deleted; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
int | delNoCommit (*hash cond, *reference sql) |
deletes rows in the table matching the condition and returns the count of rows deleted; no transaction management is performed with this method More... | |
int | delNoCommit (*hash cond, *hash opt) |
deletes rows in the table matching the condition and returns the count of rows deleted; no transaction management is performed with this method More... | |
Columns | describe () |
returns an object of class Columns describing the table More... | |
abstract private | doSelectLimitOnlyUnlockedImpl (reference sql, reference args, *hash qh) |
processes a string for use in SQL select statements when there is a "limit" argument, but no "orderby" or "offset" arguments | |
abstract private | doSelectOrderByWithOffsetSqlUnlockedImpl (reference sql, reference args, *hash qh, *hash jch, *hash ch) |
processes a string for use in SQL select statements when there is an "order by" and "offset" argument | |
drop (*hash opt) | |
drops the table from the database; releases the transaction lock after dropping the table More... | |
AbstractColumn | dropColumn (string cname, *reference lsql) |
drops a column from the table More... | |
AbstractConstraint | dropConstraint (string cname, *reference sql) |
drops a constraint from the table; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally More... | |
AbstractForeignConstraint | dropForeignConstraint (string cname, *reference sql) |
drops a foreign constraint from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally More... | |
AbstractIndex | dropIndex (string iname, *reference sql) |
drops the given index from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally More... | |
dropNoCommit (*hash opt) | |
drops the table from the database without any transaction management More... | |
AbstractPrimaryKey | dropPrimaryKey (*reference lsql) |
drops the primary key from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally More... | |
AbstractTrigger | dropTrigger (string tname, *reference sql) |
drops the given trigger from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally More... | |
bool | empty () |
returns True if the table has no definitions, False if not More... | |
bool | emptyData () |
returns True if the table has no data rows, False if not More... | |
*hash | find (any id) |
finds a row in the table with the given primary key value; if no row matches the primary key value passed then NOTHING is returned More... | |
*list | find (list ids) |
finds rows in the table with the given primary key values; if no row matches any primary key value passed then NOTHING is returned More... | |
*hash | find (hash row) |
finds a row in the table with the given primary key value given as a hash; if no row matches the primary key value passed then NOTHING is returned More... | |
*list | findAll (*hash cond) |
finds all rows in the table with the given column values; a list of hashes is returned representing the rows returned More... | |
*hash | findSingle (*hash cond) |
finds a single row in the table that match the row condition passed; multiple rows may match, but only one row will be returned from the database; if no row matches the condition hash passed then NOTHING is returned More... | |
*AbstractUniqueConstraint | findUniqueConstraint (string name) |
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary key) More... | |
string | getAddCheckConstraintSql (string cname, string src, *hash copt, *hash opt) |
returns an SQL string that can be used to add a check constraint to the table More... | |
list | getAddColumnSql (string cname, hash copt, bool nullable=True, *hash opt) |
returns a list of SQL strings that can be use to add a column to the table More... | |
string | getAddForeignConstraintSql (string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt) |
returns an SQL string that can be used to add a foreign constraint to the table More... | |
string | getAddIndexSql (string iname, bool unique, softlist cols, *hash ixopt, *hash opt) |
returns an SQL string that can be used to add an index to the table More... | |
string | getAddPrimaryKeySql (string pkname, softlist cols, *hash pkopt, *hash opt) |
returns the SQL that can be used to add a primary key to the table More... | |
list | getAddTriggerSql (string tname, string src, *hash topt, *hash opt) |
returns a list of SQL strings that can be used to add a trigger to the table More... | |
string | getAddUniqueConstraintSql (string cname, softlist cols, *hash ukopt, *hash opt) |
returns an SQL string that can be used to add a unique constraint to the table More... | |
list | getAlignSql (AbstractTable t, *hash opt) |
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure and configuration of the current table with that of the argument; if the tables are identical then an empty list is returned More... | |
string | getAlignSqlString (AbstractTable t, *hash opt) |
accepts an AbstractTable argument and returns an SQL string that could be executed to align the structure and configuration of the current table with that of the argument; if the tables are identical then an empty string is returned More... | |
private hash | getAlignTableOptions () |
returns the align table options for this driver More... | |
private hash | getCacheOptions () |
returns the cache options for this driver More... | |
private hash | getColumnDescOptions () |
returns the column description options for this driver More... | |
private hash | getColumnOperatorMap () |
returns the column operator map for this object More... | |
private hash | getColumnOptions () |
returns the column options for this driver More... | |
private hash | getConstraintOptions () |
returns the constraint options for this driver More... | |
Constraints | getConstraints () |
returns a Constraints object describing the non-foreign constraints on the table | |
*list | getCreateConstraintsSql (*hash opt, bool cache=True) |
returns a list of SQL strings that could be used to create non-foreign constraints on the table or NOTHING if there are no non-foreign constraints on the table More... | |
*list | getCreateForeignConstraintsSql (*hash opt, bool cache=True) |
returns a list of SQL strings that could be used to create foreign constraints on the table or NOTHING if there are no foreign constraints on the table More... | |
*list | getCreateIndexesSql (*hash opt, bool cache=True) |
returns a list of SQL strings that could be used to create indexes on the table or NOTHING if there are no indexes on the table More... | |
*list | getCreateMiscSql (*hash opt, bool cache=True) |
returns a list of SQL strings that could be used to create other table attributes (such as comments, if supported and present) or NOTHING if there are none More... | |
*string | getCreatePrimaryKeySql (*hash opt, bool cache=True) |
returns an SQL string that could be used to create the primary key on the table More... | |
list | getCreateSql (*hash opt) |
returns a list of SQL strings that could be used to create the table and all known properties of the table More... | |
string | getCreateSqlString (*hash opt) |
returns an SQL string that could be used to create the table and all known properties of the table More... | |
string | getCreateTableSql (*hash opt) |
returns an SQL string that could be used to create the basic table structure without indexes and constraints More... | |
*list | getCreateTriggersSql (*hash opt, bool cache=True) |
returns a list of SQL strings that could be used to create triggers on the table or NOTHING if there are no triggers on the table More... | |
list | getDropAllConstraintsAndIndexesOnColumnSql (string cname, *hash opt) |
gets a list of SQL strings to drop all constraints and indexes with the given column name; if the column does not exist then an empty list is returned More... | |
list | getDropColumnSql (string cname, *hash opt) |
returns the SQL that can be used to drop a column from the table More... | |
*string | getDropConstraintIfExistsSql (string cname, *hash opt, *reference cref) |
gets the SQL that can be used to drop a constraint from the table if it exists, otherwise returns NOTHING; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint More... | |
string | getDropConstraintSql (string cname, *hash opt) |
gets the SQL that can be used to drop a constraint from the table; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint More... | |
string | getDropIndexSql (string iname, *hash opt) |
gets the SQL that can be used to drop an index from the table More... | |
list | getDropPrimaryKeySql (*hash opt) |
gets a list of SQL strings that can be used to drop the primary key from the table More... | |
softlist | getDropSql (*hash opt) |
returns the sql required to drop the table; reimplement in subclasses if necessary More... | |
list | getDropTriggerSql (string tname, *hash opt) |
returns SQL that can be used to drop the given trigger from the table More... | |
private hash | getForeignConstraintOptions () |
return the foreign constraint options for this driver More... | |
ForeignConstraints | getForeignConstraints (*hash opt) |
returns a ForeignConstraints object describing the foreign constraints that the table has on other tables | |
Indexes | getIndexes () |
returns an object of class Indexes describing the indexes on the table More... | |
private hash | getIndexOptions () |
returns the index options for this driver More... | |
private hash | getInsertOptions () |
returns the insert options for this driver More... | |
list | getModifyColumnSql (string cname, hash copt, bool nullable=True, *hash opt) |
gets a list of SQL strings that can be used to modify an existing column in the table More... | |
string | getName () |
returns the name of the table | |
AbstractPrimaryKey | getPrimaryKey () |
returns an object of class AbstractPrimaryKey describing the primary key of the table More... | |
abstract private hash | getQoreTypeMapImpl () |
returns the qore type -> column type map | |
string | getRenameColumnSql (string old_name, string new_name, *hash opt) |
gets an SQL string that can be used to rename an existing column in the table More... | |
string | getRenameSql (string new_name, *hash opt) |
returns an SQL string that could be used to rename the table in the database More... | |
Qore::SQL::SQLStatement | getRowIterator (*hash sh, *reference sql) |
returns an SQLStatement object that will iterate the results of a select statement matching the arguments More... | |
Qore::SQL::SQLStatement | getRowIterator (*hash sh, *hash opt) |
returns an SQLStatement object that will iterate the results of a select statement matching the arguments More... | |
private hash | getSelectOptions () |
returns the select options for this driver More... | |
string | getSelectSql (*hash sh, *reference args) |
returns the SQL string to be executed corresponding to the argument hash with an output parameter for the select bind arguments More... | |
private hash | getSqlDataCallbackOptions () |
returns the sql data operation callback options for this driver More... | |
string | getSqlFromList (list l) |
returns an SQL string corresponding to the list of commands in the argument More... | |
string | getSqlName () |
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc) | |
string | getSqlValue (any v) |
returns a string for use in SQL queries representing the DB-specific value of the argument More... | |
abstract private *string | getSqlValueImpl (any v) |
returns a string for use in SQL queries representing the DB-specific value of the argument; returns NOTHING if the type cannot be converted to an SQL string | |
private hash | getTableColumnDescOptions () |
returns the table column description options for this driver More... | |
private hash | getTableCreationOptions () |
returns the table creation options for this driver More... | |
private hash | getTableDescriptionHashOptions () |
returns the table description hash options for this driver More... | |
private hash | getTableOptions () |
returns the table options for this driver More... | |
private hash | getTriggerOptions () |
returns the trigger options for this driver More... | |
Triggers | getTriggers () |
returns an object of class Triggers describing the triggers on the table More... | |
string | getTruncateSql (*hash opt) |
gets the SQL that can be used to truncate the table More... | |
abstract private hash | getTypeMapImpl () |
returns the type name -> type description hash | |
Qore::AbstractIterator | getUniqueConstraintIterator () |
returns an iterator for all unique constraints on the table (including the primary key if any) More... | |
private hash | getUpdateOperatorMap () |
returns the update operator map for this object More... | |
code | getUpsertClosure (hash example_row, int upsert_strategy=UpsertAuto) |
returns a closure that can be executed given a hash argument representing a single row that will be updated or inserted in the database with the given upsert strategy; the table must have a unique key to do this; the closure returned does not check the input hash for validity More... | |
code | getUpsertClosureWithValidation (hash example_row, int upsert_strategy=UpsertAuto) |
returns a closure that can be executed given a hash argument representing a single row that will be updated or inserted in the database with the given upsert strategy; the table must have a unique key to do this; the closure returned checks the input hash for validity More... | |
private hash | getUpsertOptions () |
returns the upsert options for this driver More... | |
private hash | getWhereOperatorMap () |
returns the "where" operator map for this object More... | |
bool | inDb () |
returns True if the table has been read from or created in the database, False if not More... | |
insert (hash row, *reference sql) | |
inserts a row into the table; the transaction is committed if successful, if an error occurs, it is rolled back More... | |
insert (hash row, *hash opt) | |
inserts a row into the table; the transaction is committed if successful, if an error occurs, it is rolled back More... | |
int | insertFromIterator (Qore::AbstractIterator i, *hash opt) |
this method inserts data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
int | insertFromIteratorNoCommit (Qore::AbstractIterator i, *hash opt) |
this method inserts data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; no transaction management is performed with this method More... | |
int | insertFromSelect (list cols, AbstractTable source, *hash sh, *reference sql) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); the transaction is committed if successful, if an error occurs, it is rolled back More... | |
int | insertFromSelect (list cols, AbstractTable source, *hash sh, *hash opt) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); the transaction is committed if successful, if an error occurs, it is rolled back More... | |
int | insertFromSelectNoCommit (list cols, AbstractTable source, *hash sh, *reference sql) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); a transaction will be in progress after this method is successfully executed More... | |
int | insertFromSelectNoCommit (list cols, AbstractTable source, *hash sh, *hash opt) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); a transaction will be in progress after this method is successfully executed More... | |
insertNoCommit (hash row, *reference sql) | |
inserts a row into the table without any transaction management; a transaction will be in progress after this method is successfully executed More... | |
insertNoCommit (hash row, *hash opt) | |
inserts a row into the table without any transaction management; a transaction will be in progress after this method is successfully executed More... | |
AbstractColumn | modifyColumn (string cname, hash opt, bool nullable=True, *reference lsql) |
modifies an existing column in the table; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally and the new column definition will be created when create() is called for example More... | |
AbstractForeignConstraint | removeForeignConstraint (string cname) |
removes the named foreign constraint from the table; no SQL is executed in any case, only the named foreign constraint is removed from the table definition More... | |
rename (string new_name, *reference sql, *Tables table_cache) | |
renames the table; if the table is already known to be in the database in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally More... | |
AbstractColumn | renameColumn (string old_name, string new_name, reference sql) |
renames an existing column; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally More... | |
AbstractConstraint | renameConstraint (string old_name, string new_name, reference lsql) |
renames an existing constraint; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally More... | |
AbstractIndex | renameIndex (string old_name, string new_name, reference sql) |
renames an existing index; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally More... | |
rollback () | |
rolls back the current transaction on the underlying Qore::SQL::AbstractDatasource | |
softint | rowCount () |
returns the number of rows in the table More... | |
*hash | select (*hash sh, *reference sql) |
returns a hash of lists representing the columns and rows in the table that match the argument hahs More... | |
*hash | select (*hash sh, *hash opt) |
returns a hash of lists representing the columns and rows in the table that match the argument hahs More... | |
*hash | selectRow (*hash sh, *reference sql) |
returns a hash representing the row in the table that matches the argument hash; if more than one row would be returned an exception is raised More... | |
*hash | selectRow (*hash sh, *hash opt) |
returns a hash representing the row in the table that matches the argument hash; if more than one row would be returned an exception is raised More... | |
*list | selectRows (*hash sh, *reference sql) |
returns a list of hashes representing the rows in the table that match the argument hash More... | |
*list | selectRows (*hash sh, *hash opt) |
returns a list of hashes representing the rows in the table that match the argument hash More... | |
setDatasource (AbstractDatasource nds) | |
changes the datasource for the table; if the inDb flag is True, then it is set to False by calling this method More... | |
setupTable (hash desc, *hash opt) | |
creates the object from a table description hash More... | |
abstract private bool | supportsTablespacesImpl () |
returns True if the database support tablespaces | |
truncate () | |
truncates all the table data; releases the transaction lock after executing More... | |
truncateNoCommit () | |
truncates all the table data without any transaction management More... | |
any | tryExec (string sql) |
executes some SQL with optional arguments so that if an error occurs the current transaction state is not lost More... | |
any | tryExecArgs (string sql, *softlist args) |
executes some SQL with optional arguments so that if an error occurs the current transaction state is not lost More... | |
private any | tryExecArgsImpl (string sql, *softlist args) |
tries to execute a command so that if an error occurs the current transaction status is not lost | |
any | tryExecRaw (string sql) |
executes some SQL so that if an error occurs the current transaction state is not lost More... | |
private any | tryExecRawImpl (string sql) |
tries to execute a command so that if an error occurs the current transaction status is not lost | |
abstract private bool | tryInsertImpl (string sql, hash row) |
tries to insert a row, if there is a duplicate key, then it returns False, if successful, returns True | |
abstract private bool | uniqueIndexCreatesConstraintImpl () |
returns True if the database automatically creates a unique constraint when a unique index is created (ex: mysql) | |
int | update (hash set, *hash cond, *reference sql) |
updates rows in the table matching an optional condition and returns the count of rows updated; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
int | update (hash set, *hash cond, *hash opt) |
updates rows in the table matching an optional condition and returns the count of rows updated; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
int | updateNoCommit (hash set, *hash cond, *reference sql) |
updates rows in the table matching an optional condition and returns the count of rows updated; no transaction management is performed with this method More... | |
int | updateNoCommit (hash set, *hash cond, *hash opt) |
updates rows in the table matching an optional condition and returns the count of rows updated; no transaction management is performed with this method More... | |
int | upsert (hash row, int upsert_strategy=UpsertAuto) |
update or insert the data in the table according to the hash argument; the table must have a unique key to do this; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
*hash | upsertFromIterator (Qore::AbstractIterator i, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
*hash | upsertFromIteratorNoCommit (Qore::AbstractIterator i, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; no transaction management is performed with this method More... | |
*hash | upsertFromSelect (AbstractTable t, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given foreign table and select option hash into the current table; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
*hash | upsertFromSelect (Table t, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given foreign table and select option hash into the current table; the transaction is committed if successful, if an error occurs then it is rolled back More... | |
*hash | upsertFromSelectNoCommit (AbstractTable t, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given foreign table and select option hash into the current table; no transaction management is performed with this method More... | |
*hash | upsertFromSelectNoCommit (Table t, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt) |
this method upserts or merges data from the given foreign table and select option hash into the current table; no transaction management is performed with this method More... | |
int | upsertNoCommit (hash row, int upsert_strategy=UpsertAuto) |
update or insert the data in the table according to the hash argument; the table must have a unique key to do this More... | |
private | validateColumnOptions (string cname, reference opt, bool nullable) |
validates column options | |
![]() | |
private | constructor (AbstractDatasource nds, *hash nopts) |
creates the object; private constructor More... | |
Qore::SQL::AbstractDatasource | getDatasource () |
gets the underlying AbstractDatasource | |
string | getDatasourceDesc () |
returns a descriptive string for the datasource | |
string | getDriverName () |
returns the database driver name | |
Public Attributes | |
const | AdditionalColumnDescOptions |
additional column description keys valid when describing columns in a table description hash More... | |
const | AlignTableOptions |
table alignment options More... | |
const | CacheOptions |
default cache options | |
const | ColumnDescOptions |
Column description options. More... | |
const | ColumnOptions = hash() |
Column options; this is currently empty and can be extended in database-specific modules. | |
const | ConstraintOptions = IndexOptions |
default constraint options More... | |
const | ForeignConstraintOptions |
default foreign constraint options More... | |
const | IndexOptions |
default index options More... | |
const | InsertOptions |
default insert option keys More... | |
const | SelectOptions |
default select options More... | |
const | SqlDataCallbackOptions |
generic SQL data operation callbacks More... | |
const | TableCreationOptions |
table creation options More... | |
const | TableDescriptionHashOptions |
Table description options. More... | |
const | TableOmissionOptions |
alignment omission options | |
const | TableOptions |
table options More... | |
const | TriggerOptions = AbstractDatabase::CreationOptions |
default trigger options More... | |
const | UpsertAuto = 4 |
Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst. More... | |
const | UpsertInsertFirst = 1 |
Upsert option: insert first, if the insert fails, then update. More... | |
const | UpsertInsertOnly = 5 |
Upsert option: insert if the row does not exist, otherwise ignore. More... | |
const | UpsertOptions |
default upsert option keys More... | |
const | UpsertResultDescriptionMap |
hash mapping upsert descriptions to codes More... | |
const | UpsertResultLetterMap |
maps upsert result codes to single letter symbols | |
const | UpsertResultMap |
hash mapping upsert results to a description More... | |
const | UpsertSelectFirst = 3 |
Upsert option: select first, if the row is unchanged, do nothing, if it doesn't exist, insert, otherwise update. More... | |
const | UpsertUpdateFirst = 2 |
Upsert option: update first, if the update fails, then insert. More... | |
const | UR_Deleted = 5 |
row was deleted (only possible with batch upsert methods such as Table::upsertFromIterator() where upsert option delete_others is True) | |
const | UR_Inserted = 1 |
row was inserted | |
const | UR_Unchanged = 4 |
row was unchanged (only possible with UpsertSelectFirst) | |
const | UR_Updated = 3 |
row was updated because it was different (only possible with UpsertSelectFirst) | |
const | UR_Verified = 2 |
row was updated unconditionally (not returned with UpsertSelectFirst) | |
Private Attributes | |
Columns | columns |
column description object | |
Constraints | constraints |
constraint descriptions | |
ForeignConstraints | foreignConstraints |
foreign constraints description | |
bool | inDb = False |
in database | |
Indexes | indexes |
index descriptions | |
bool | manual = False |
manual edits | |
string | name |
the table's name | |
bool | native_case = False |
native case option | |
AbstractPrimaryKey | primaryKey |
primary key description | |
Triggers | triggers |
trigger descriptions | |
the base abstract class for the table implementation
AbstractCheckConstraint SqlUtil::AbstractTable::addCheckConstraint | ( | string | cname, |
string | src, | ||
*hash | opt, | ||
*reference | sql | ||
) |
adds a check constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the new constraint |
src | the source of the constraint clause |
opt | a hash of options for the new constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
CHECK-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns or options were passed |
AbstractColumn SqlUtil::AbstractTable::addColumn | ( | string | cname, |
hash | opt, | ||
bool | nullable = True , |
||
*reference | lsql | ||
) |
adds a column to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the column |
opt | a hash describing the column; the following keys are permitted (other column options may be supported depending on the underlying AbstractTable implementation):
|
nullable | if True then the column can hold NULL values; note that primary key columns cannot be nullable |
lsql | an optional reference to a list of strings to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
COLUMN-ERROR | no native_type or qore_type keys in column option hash, column already exists, invalid column data |
default_value
value when adding a column with a "not null"
constraint with existing dataAbstractForeignConstraint SqlUtil::AbstractTable::addForeignConstraint | ( | string | cname, |
softlist | cols, | ||
string | table, | ||
*softlist | tcols, | ||
*hash | opt, | ||
*reference | sql | ||
) |
adds a foreign constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the new foreign constraint |
cols | a single column name or a list of columns in the local table that make up the foreign constraint |
table | the name of the other table that the constraint targets |
tcols | a single column name or a list of columns in the foreign table or NOTHING meaning that the column names are the same as in the local table; if column names are given the same number of columns must be given in the local and foreign tables |
opt | a hash of options for the new foreign constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ForeignConstraintOptions |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
FOREIGN-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns or options were passed |
AbstractIndex SqlUtil::AbstractTable::addIndex | ( | string | iname, |
bool | unique, | ||
softlist | cols, | ||
*hash | opt, | ||
*reference | sql | ||
) |
adds an index to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
iname | the name of the new index |
unique | a flag to tell if the new index should be unique or not |
cols | a single column name or a list of columns that make up the index |
opt | a hash of options for the new index; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::IndexOptions |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
INDEX-ERROR | the table already has an index with the given name or invalid columns or options were passed |
AbstractPrimaryKey SqlUtil::AbstractTable::addPrimaryKey | ( | string | pkname, |
softlist | cols, | ||
*hash | opt, | ||
*reference | sql | ||
) |
adds a primary key to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
pkname | the name of the new primary key constraint |
cols | a single column name or a list of columns that make up the primary key |
opt | a hash of options for the new primary key; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
PRIMARY-KEY-ERROR | the table already has a primary key or invalid columns or options passed |
AbstractTrigger SqlUtil::AbstractTable::addTrigger | ( | string | tname, |
string | src, | ||
*hash | opt, | ||
*reference | lsql | ||
) |
adds a trigger to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
tname | the name of the new trigger |
src | the source of the trigger |
opt | a hash of options for the new trigger; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::TriggerOptions |
lsql | an optional reference to a list of strings to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
TRIGGER-ERROR | the table already has a trigger with the given name or invalid options were passed |
AbstractUniqueConstraint SqlUtil::AbstractTable::addUniqueConstraint | ( | string | cname, |
softlist | cols, | ||
*hash | opt, | ||
*reference | sql | ||
) |
adds a unique constraint to the table; if the table is known to be in the database already, then the constraint is added to the database also immediately; otherwise it is only added internally and can be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the new unique constraint |
cols | a single column name or a list of columns that make up the unique constraint |
opt | a hash of options for the new unique constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
UNIQUE-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns passed |
OPTION-ERROR | invalid or unsupported option passed |
SqlUtil::AbstractTable::cache | ( | *hash | opts | ) |
reads in all attributes of the table from the database
opts | cache options; see SqlUtil::AbstractTable::CacheOptions for common options; each driver can support additional driver-specific options |
|
pure virtual |
SqlUtil::AbstractTable::clear | ( | ) |
purges the current table definition
creates the object; private constructor
nds | the AbstractDatasource for the connection to the database |
nname | the name of the table |
nopts | 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 |
OPTION-ERROR | invalid or unsupported option passed |
SqlUtil::AbstractTable::create | ( | *hash | opt | ) |
creates the table in the database; releases the transaction lock after creating the table
opt | a hash of options for the SQL creation strings |
SqlUtil::AbstractTable::createNoCommit | ( | *hash | opt | ) |
creates the table with all associated properties (indexes, constraints, etc) without any transaction management
opt | a hash of options for the SQL creation strings |
CREATE-TABLE-ERROR | table has already been read from or created in the database |
deletes rows in the table matching the condition and returns the count of rows deleted; the transaction is committed if successful, if an error occurs then it is rolled back
cond | a hash of conditions for the where clause; see Where Clauses for more information |
sql | an optional reference to a string to return the SQL generated for the select statement |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
deletes rows in the table matching the condition and returns the count of rows deleted; the transaction is committed if successful, if an error occurs then it is rolled back
cond | a hash of conditions for the where clause; see Where Clauses for more information |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
deletes rows in the table matching the condition and returns the count of rows deleted; no transaction management is performed with this method
cond | a hash of conditions for the where clause; see Where Clauses for more information |
sql | an optional reference to a string to return the SQL generated for the select statement |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
deletes rows in the table matching the condition and returns the count of rows deleted; no transaction management is performed with this method
cond | a hash of conditions for the where clause; see Where Clauses for more information |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
Columns SqlUtil::AbstractTable::describe | ( | ) |
SqlUtil::AbstractTable::drop | ( | *hash | opt | ) |
drops the table from the database; releases the transaction lock after dropping the table
opt | optional callback options; see AbstractDatabase::CallbackOptions for more info |
OPTION-ERROR | invalid or unknown callback option |
AbstractColumn SqlUtil::AbstractTable::dropColumn | ( | string | cname, |
*reference | lsql | ||
) |
drops a column from the table
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the column to drop |
lsql | an optional reference to a list of strings to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
COLUMN-ERROR | the named column is not present in the table |
AbstractConstraint SqlUtil::AbstractTable::dropConstraint | ( | string | cname, |
*reference | sql | ||
) |
drops a constraint from the table; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the constraint to drop |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
CONSTRAINT-ERROR | the given constraint does not exist in the table |
AbstractForeignConstraint SqlUtil::AbstractTable::dropForeignConstraint | ( | string | cname, |
*reference | sql | ||
) |
drops a foreign constraint from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the foreign constraint to drop |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
FOREIGN-CONSTRAINT-ERROR | the given constraint does not exist |
AbstractIndex SqlUtil::AbstractTable::dropIndex | ( | string | iname, |
*reference | sql | ||
) |
drops the given index from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
iname | the name of the index to drop |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
INDEX-ERROR | the given index does not exist |
SqlUtil::AbstractTable::dropNoCommit | ( | *hash | opt | ) |
drops the table from the database without any transaction management
opt | optional callback options; see AbstractDatabase::CallbackOptions for more info |
OPTION-ERROR | invalid or unknown callback option |
AbstractPrimaryKey SqlUtil::AbstractTable::dropPrimaryKey | ( | *reference | lsql | ) |
drops the primary key from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
lsql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
PRIMARY-KEY-ERROR | no primary key exists |
AbstractTrigger SqlUtil::AbstractTable::dropTrigger | ( | string | tname, |
*reference | sql | ||
) |
drops the given trigger from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
tname | the name of the trigger to drop |
sql | an optional reference to a string to retrieve the SQL used to modify the database (only executed if the table is already in the database) |
TRIGGER-ERROR | the given trigger does not exist |
bool SqlUtil::AbstractTable::empty | ( | ) |
returns True if the table has no definitions, False if not
bool SqlUtil::AbstractTable::emptyData | ( | ) |
*hash SqlUtil::AbstractTable::find | ( | any | id | ) |
finds rows in the table with the given primary key values; if no row matches any primary key value passed then NOTHING is returned
ids | the list of primary key IDs to find; if the list is empty then NOTHING is returned |
PRIMARY-KEY-ERROR | the table has no primary key or the primary key has more than one column |
finds a row in the table with the given primary key value given as a hash; if no row matches the primary key value passed then NOTHING is returned
row | a hash giving the primary key value to find; other columns may also appear in the hash, however at least all columns of the primary key must be present |
PRIMARY-KEY-ERROR | the table has no primary key or the the hash passed does not contain all columns of the primary key |
finds all rows in the table with the given column values; a list of hashes is returned representing the rows returned
cond | a hash giving the column values to find; see Where Clauses for the format of this argument |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
where
= cond
finds a single row in the table that match the row condition passed; multiple rows may match, but only one row will be returned from the database; if no row matches the condition hash passed then NOTHING is returned
cond | a hash giving the column values to find; see Where Clauses for the format of this argument |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
where
= cond
and limit
= 1 *AbstractUniqueConstraint SqlUtil::AbstractTable::findUniqueConstraint | ( | string | name | ) |
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary key)
name | the name of the unique constraint to find |
string SqlUtil::AbstractTable::getAddCheckConstraintSql | ( | string | cname, |
string | src, | ||
*hash | copt, | ||
*hash | opt | ||
) |
returns an SQL string that can be used to add a check constraint to the table
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the new constraint |
src | the source of the constraint clause |
copt | a hash of options for the new constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
CHECK-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns or options were passed |
list SqlUtil::AbstractTable::getAddColumnSql | ( | string | cname, |
hash | copt, | ||
bool | nullable = True , |
||
*hash | opt | ||
) |
returns a list of SQL strings that can be use to add a column to the table
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the column |
copt | a hash describing the column; the following keys are permitted (other column options may be supported depending on the underlying AbstractTable implementation):
|
nullable | if True then the column can hold NULL values; note that primary key columns cannot be nullable |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
COLUMN-ERROR | no native_type or qore_type keys in column option hash, column already exists, invalid column data |
default_value
value when adding a column with a "not null"
constraint with existing datastring SqlUtil::AbstractTable::getAddForeignConstraintSql | ( | string | cname, |
softlist | cols, | ||
string | table, | ||
*softlist | tcols, | ||
*hash | fkopt, | ||
*hash | opt | ||
) |
returns an SQL string that can be used to add a foreign constraint to the table
cname | the name of the new foreign constraint |
cols | a single column name or a list of columns in the local table that make up the foreign constraint |
table | the name of the other table that the constraint targets |
tcols | a single column name or a list of columns in the foreign table or NOTHING meaning that the column names are the same as in the local table; if column names are given the same number of columns must be given in the local and foreign tables |
fkopt | a hash of options for the new foreign constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ForeignConstraintOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
FOREIGN-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns or options were passed |
string SqlUtil::AbstractTable::getAddIndexSql | ( | string | iname, |
bool | unique, | ||
softlist | cols, | ||
*hash | ixopt, | ||
*hash | opt | ||
) |
returns an SQL string that can be used to add an index to the table
iname | the name of the new index |
unique | a flag to tell if the new index should be unique or not |
cols | a single column name or a list of columns that make up the index |
ixopt | a hash of options for the new index; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::IndexOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
INDEX-ERROR | the table already has an index with the given name or invalid columns or options were passed |
string SqlUtil::AbstractTable::getAddPrimaryKeySql | ( | string | pkname, |
softlist | cols, | ||
*hash | pkopt, | ||
*hash | opt | ||
) |
returns the SQL that can be used to add a primary key to the table
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
pkname | the name of the new primary key constraint |
cols | a single column name or a list of columns that make up the primary key |
pkopt | a hash of options for the new primary key; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
PRIMARY-KEY-ERROR | the table already has a primary key or invalid columns or options passed |
returns a list of SQL strings that can be used to add a trigger to the table
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
tname | the name of the new trigger |
src | the source of the trigger |
topt | a hash of options for the new trigger; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::TriggerOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
TRIGGER-ERROR | the table already has a trigger with the given name or invalid options were passed |
string SqlUtil::AbstractTable::getAddUniqueConstraintSql | ( | string | cname, |
softlist | cols, | ||
*hash | ukopt, | ||
*hash | opt | ||
) |
returns an SQL string that can be used to add a unique constraint to the table
cname | the name of the new unique constraint |
cols | a single column name or a list of columns that make up the unique constraint |
ukopt | a hash of options for the new unique constraint; each driver may implement its own options; for common options, see SqlUtil::AbstractTable::ConstraintOptions |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
UNIQUE-CONSTRAINT-ERROR | the table already has a constraint with the given name or invalid columns passed |
list SqlUtil::AbstractTable::getAlignSql | ( | AbstractTable | t, |
*hash | opt | ||
) |
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure and configuration of the current table with that of the argument; if the tables are identical then an empty list is returned
t | the template table that the current table will be compared to |
opt | a hash of options for the SQL creation string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
ALIGN-TABLE-ERROR | the argument must be of the same class as the current object; template table has no columns |
OPTION-ERROR | invalid or unsupported option passed |
string SqlUtil::AbstractTable::getAlignSqlString | ( | AbstractTable | t, |
*hash | opt | ||
) |
accepts an AbstractTable argument and returns an SQL string that could be executed to align the structure and configuration of the current table with that of the argument; if the tables are identical then an empty string is returned
t | the template table that the current table will be compared to |
opt | a hash of options for the SQL creation string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
ALIGN-TABLE-ERROR | the argument must be of the same class as the current object; template table has no columns |
OPTION-ERROR | invalid or unsupported option passed |
private hash SqlUtil::AbstractTable::getAlignTableOptions | ( | ) |
returns the align table options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getCacheOptions | ( | ) |
returns the cache options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getColumnDescOptions | ( | ) |
returns the column description options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getColumnOperatorMap | ( | ) |
returns the column operator map for this object
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getColumnOptions | ( | ) |
returns the column options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getConstraintOptions | ( | ) |
returns the constraint options for this driver
override in subclasses to return driver-specific options
returns a list of SQL strings that could be used to create non-foreign constraints on the table or NOTHING if there are no non-foreign constraints on the table
opt | a hash of options for the non-foreign constraint creation string; see SqlUtil::AbstractTable::ConstraintOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
returns a list of SQL strings that could be used to create foreign constraints on the table or NOTHING if there are no foreign constraints on the table
opt | a hash of options for the foreign constraint creation string; see SqlUtil::AbstractTable::ForeignConstraintOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
returns a list of SQL strings that could be used to create indexes on the table or NOTHING if there are no indexes on the table
opt | a hash of options for the index creation string; see SqlUtil::AbstractTable::IndexOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
returns a list of SQL strings that could be used to create other table attributes (such as comments, if supported and present) or NOTHING if there are none
opt | a hash of options for the SQL creation string; see TableCreationOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
returns an SQL string that could be used to create the primary key on the table
opt | a hash of options for the primary key creation string; see SqlUtil::AbstractTable::ConstraintOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
returns a list of SQL strings that could be used to create the table and all known properties of the table
opt | a hash of options for the table, index, and constraint creation strings; see TableCreationOptions for common options; each driver can support additional driver-specific options |
returns an SQL string that could be used to create the table and all known properties of the table
opt | a hash of options for the SQL creation string |
returns an SQL string that could be used to create the basic table structure without indexes and constraints
opt | a hash of options for the table creation string; see TableCreationOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
returns a list of SQL strings that could be used to create triggers on the table or NOTHING if there are no triggers on the table
opt | a hash of options for the trigger creation strings; see TableCreationOptions for common options; each driver can support additional driver-specific options |
cache | read in data from the database for uncached properties of the table |
OPTION-ERROR | invalid or unsupported option passed |
gets a list of SQL strings to drop all constraints and indexes with the given column name; if the column does not exist then an empty list is returned
cname | the name of the column |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
returns the SQL that can be used to drop a column from the table
cname | the name of the column to drop |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
COLUMN-ERROR | the named column is not present in the table |
*string SqlUtil::AbstractTable::getDropConstraintIfExistsSql | ( | string | cname, |
*hash | opt, | ||
*reference | cref | ||
) |
gets the SQL that can be used to drop a constraint from the table if it exists, otherwise returns NOTHING; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint
cname | the name of the constraint to drop |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
cref | an optional reference to an AbstractConstraint object that will return the constraint dropped |
OPTION-ERROR | invalid or unsupported option passed |
gets the SQL that can be used to drop a constraint from the table; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint
cname | the name of the constraint to drop |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
CONSTRAINT-ERROR | the given constraint does not exist in the table |
gets the SQL that can be used to drop an index from the table
iname | the name of the index to drop |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
INDEX-ERROR | the given index does not exist in the table |
gets a list of SQL strings that can be used to drop the primary key from the table
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
PRIMARY-KEY-ERROR | the table has no primary key |
softlist SqlUtil::AbstractTable::getDropSql | ( | *hash | opt | ) |
returns the sql required to drop the table; reimplement in subclasses if necessary
opt | optional callback options; see AbstractDatabase::CallbackOptions for more info |
OPTION-ERROR | invalid or unknown callback option |
returns SQL that can be used to drop the given trigger from the table
tname | the name of the trigger to drop |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
TRIGGER-ERROR | the given trigger does not exist |
private hash SqlUtil::AbstractTable::getForeignConstraintOptions | ( | ) |
return the foreign constraint options for this driver
override in subclasses to return driver-specific options
Indexes SqlUtil::AbstractTable::getIndexes | ( | ) |
returns an object of class Indexes describing the indexes on the table
If there are no indexes on the table then the object returned will be empty (see SqlUtil::Indexes::empty())
private hash SqlUtil::AbstractTable::getIndexOptions | ( | ) |
returns the index options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getInsertOptions | ( | ) |
returns the insert options for this driver
override in subclasses to return driver-specific options
list SqlUtil::AbstractTable::getModifyColumnSql | ( | string | cname, |
hash | copt, | ||
bool | nullable = True , |
||
*hash | opt | ||
) |
gets a list of SQL strings that can be used to modify an existing column in the table
cname | the name of the column |
copt | a hash describing the column; the following keys are permitted (other column options may be supported depending on the underlying AbstractTable implementation):
|
nullable | if True then the column can hold NULL values; note that primary key columns cannot be nullable |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
COLUMN-ERROR | no native_type or qore_type keys in column option hash, column does not exist, invalid column data |
default_value
value when modifying a column to have a "not null"
constraint with existing dataAbstractPrimaryKey SqlUtil::AbstractTable::getPrimaryKey | ( | ) |
returns an object of class AbstractPrimaryKey describing the primary key of the table
If there is no primary key then the object returned will be empty (see SqlUtil::AbstractPrimaryKey::empty())
gets an SQL string that can be used to rename an existing column in the table
old_name | the current name of the column |
new_name | the new name of the column |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
COLUMN-ERROR | if the old column does not exist in the table or the new column already does |
returns an SQL string that could be used to rename the table in the database
new_name | the new name for the table |
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
"db_table_cache"
option key is assigned to a Tables argument, then the table cache is also updated with the name change in this caseQore::SQL::SQLStatement SqlUtil::AbstractTable::getRowIterator | ( | *hash | sh, |
*reference | sql | ||
) |
returns an SQLStatement object that will iterate the results of a select statement matching the arguments
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automaticallyQore::SQL::SQLStatement SqlUtil::AbstractTable::getRowIterator | ( | *hash | sh, |
*hash | opt | ||
) |
returns an SQLStatement object that will iterate the results of a select statement matching the arguments
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automaticallyprivate hash SqlUtil::AbstractTable::getSelectOptions | ( | ) |
returns the select options for this driver
override in subclasses to return driver-specific options
returns the SQL string to be executed corresponding to the argument hash with an output parameter for the select bind arguments
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
args | an optional reference to a list for any bind arguments |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically private hash SqlUtil::AbstractTable::getSqlDataCallbackOptions | ( | ) |
returns the sql data operation callback options for this driver
override in subclasses to return driver-specific options
returns an SQL string corresponding to the list of commands in the argument
l | a list of SQL commands |
string SqlUtil::AbstractTable::getSqlValue | ( | any | v | ) |
returns a string for use in SQL queries representing the DB-specific value of the argument
v | the value to convert to an SQL value |
VALUE-ERROR | the given value cannot be converted to an SQL string (missing rules for value) |
private hash SqlUtil::AbstractTable::getTableColumnDescOptions | ( | ) |
returns the table column description options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getTableCreationOptions | ( | ) |
returns the table creation options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getTableDescriptionHashOptions | ( | ) |
returns the table description hash options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getTableOptions | ( | ) |
returns the table options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getTriggerOptions | ( | ) |
returns the trigger options for this driver
override in subclasses to return driver-specific options
Triggers SqlUtil::AbstractTable::getTriggers | ( | ) |
returns an object of class Triggers describing the triggers on the table
If there are no triggers on the table then the object returned will be empty (see SqlUtil::Triggers::empty())
gets the SQL that can be used to truncate the table
opt | a hash of options for the SQL string; see SqlUtil::AbstractTable::AlignTableOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option passed |
Qore::AbstractIterator SqlUtil::AbstractTable::getUniqueConstraintIterator | ( | ) |
private hash SqlUtil::AbstractTable::getUpdateOperatorMap | ( | ) |
returns the update operator map for this object
override in subclasses to return driver-specific options
code SqlUtil::AbstractTable::getUpsertClosure | ( | hash | example_row, |
int | upsert_strategy = UpsertAuto |
||
) |
returns a closure that can be executed given a hash argument representing a single row that will be updated or inserted in the database with the given upsert strategy; the table must have a unique key to do this; the closure returned does not check the input hash for validity
example_row | a hash representing an example row to insert or update; every row passed to the upsert closure returned must have the same keys in the same order |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
code SqlUtil::AbstractTable::getUpsertClosureWithValidation | ( | hash | example_row, |
int | upsert_strategy = UpsertAuto |
||
) |
returns a closure that can be executed given a hash argument representing a single row that will be updated or inserted in the database with the given upsert strategy; the table must have a unique key to do this; the closure returned checks the input hash for validity
example_row | a hash representing an example row to insert or update; every row passed to the upsert closure returned must have the same keys in the same order or the closure returned will throw an UPSERT-ERROR exception |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
UPSERT-ERROR
exception; see SqlUtil::AbstractTable::getUpsertClosure() for a similar method that returns a non-validating closure; the closure returned by this method is a little slower than the one returned by SqlUtil::AbstractTable::getUpsertClosure() since each row is validated private hash SqlUtil::AbstractTable::getUpsertOptions | ( | ) |
returns the upsert options for this driver
override in subclasses to return driver-specific options
private hash SqlUtil::AbstractTable::getWhereOperatorMap | ( | ) |
returns the "where" operator map for this object
override in subclasses to return driver-specific options
bool SqlUtil::AbstractTable::inDb | ( | ) |
SqlUtil::AbstractTable::insert | ( | hash | row, |
*reference | sql | ||
) |
inserts a row into the table; the transaction is committed if successful, if an error occurs, it is rolled back
row | a hash representing the row to insert |
sql | an optional reference to a string to return the SQL generated for the insert statement |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
inserts a row into the table; the transaction is committed if successful, if an error occurs, it is rolled back
row | a hash representing the row to insert |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
int SqlUtil::AbstractTable::insertFromIterator | ( | Qore::AbstractIterator | i, |
*hash | opt | ||
) |
this method inserts data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; the transaction is committed if successful, if an error occurs then it is rolled back
i | the Qore::AbstractIterator argument that will provide the data to insert into the current table; the getValue() method of this object must return a hash giving row values (for example, the Qore::SQL::SQLStatement class is well-suited to be used here); note that the iterator is assumed to return the same columns in every element |
opt | a hash of options for the insert operation; see SqlUtil::AbstractTable::InsertOptions for common options; each driver can support additional driver-specific options |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
int SqlUtil::AbstractTable::insertFromIteratorNoCommit | ( | Qore::AbstractIterator | i, |
*hash | opt | ||
) |
this method inserts data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; no transaction management is performed with this method
i | the Qore::AbstractIterator argument that will provide the data to insert into the current table; the getValue() method of this object must return a hash giving row values (for example, the Qore::SQL::SQLStatement class is well-suited to be used here); note that the iterator is assumed to return the same columns in the same order in every element |
opt | a hash of options for the insert operation; see SqlUtil::AbstractTable::InsertOptions for common options; each driver can support additional driver-specific options; note that this method ignores any "commit_block" option |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
int SqlUtil::AbstractTable::insertFromSelect | ( | list | cols, |
AbstractTable | source, | ||
*hash | sh, | ||
*reference | sql | ||
) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); the transaction is committed if successful, if an error occurs, it is rolled back
cols | the list of column names to use to insert in the current table |
source | the source table for the select statement |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | unknown or invalid column in insert list |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
int SqlUtil::AbstractTable::insertFromSelect | ( | list | cols, |
AbstractTable | source, | ||
*hash | sh, | ||
*hash | opt | ||
) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); the transaction is committed if successful, if an error occurs, it is rolled back
cols | the list of column names to use to insert in the current table |
source | the source table for the select statement |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | unknown or invalid column in insert list |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
int SqlUtil::AbstractTable::insertFromSelectNoCommit | ( | list | cols, |
AbstractTable | source, | ||
*hash | sh, | ||
*reference | sql | ||
) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); a transaction will be in progress after this method is successfully executed
cols | the list of column names to use to insert in the current table |
source | the source table for the select statement |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | unknown or invalid column in insert list |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
int SqlUtil::AbstractTable::insertFromSelectNoCommit | ( | list | cols, |
AbstractTable | source, | ||
*hash | sh, | ||
*hash | opt | ||
) |
inserts rows into a table based on a select statement from another table (which must be using the same datasource as the current table); a transaction will be in progress after this method is successfully executed
cols | the list of column names to use to insert in the current table |
source | the source table for the select statement |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | unknown or invalid column in insert list |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
SqlUtil::AbstractTable::insertNoCommit | ( | hash | row, |
*reference | sql | ||
) |
inserts a row into the table without any transaction management; a transaction will be in progress after this method is successfully executed
row | a hash representing the row to insert |
sql | an optional reference to a string to return the SQL generated for the insert statement |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
inserts a row into the table without any transaction management; a transaction will be in progress after this method is successfully executed
row | a hash representing the row to insert |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
AbstractColumn SqlUtil::AbstractTable::modifyColumn | ( | string | cname, |
hash | opt, | ||
bool | nullable = True , |
||
*reference | lsql | ||
) |
modifies an existing column in the table; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally and the new column definition will be created when create() is called for example
In case the table is already in the database, this method commits the transaction on success and rolls back the transaction if there's an error.
cname | the name of the column |
opt | a hash describing the column; the following keys are permitted (other column options may be supported depending on the underlying AbstractTable implementation):
|
lsql | an optional reference to a list of strings to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
nullable | if True then the column can hold NULL values; note that primary key columns cannot be nullable |
COLUMN-ERROR | no native_type or qore_type keys in column option hash, column does not exist, invalid column data |
default_value
value when modifying a column to have a "not null"
constraint with existing dataAbstractForeignConstraint SqlUtil::AbstractTable::removeForeignConstraint | ( | string | cname | ) |
removes the named foreign constraint from the table; no SQL is executed in any case, only the named foreign constraint is removed from the table definition
cname | the name of the foreign constraint to remove |
FOREIGN-CONSTRAINT-ERROR | the given constraint does not exist |
renames the table; if the table is already known to be in the database in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally
new_name | the new name for the table |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
table_cache | an optional Tables argument to update the table name in any table cache |
AbstractColumn SqlUtil::AbstractTable::renameColumn | ( | string | old_name, |
string | new_name, | ||
reference | sql | ||
) |
renames an existing column; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally
old_name | the current name of the column |
new_name | the new name of the column |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
COLUMN-ERROR | if the given column does not exist in the table |
AbstractConstraint SqlUtil::AbstractTable::renameConstraint | ( | string | old_name, |
string | new_name, | ||
reference | lsql | ||
) |
renames an existing constraint; this can be any constraint on the table, a primary key, a foreign key constraint, or a generic constraint; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally
old_name | the current name of the constraint |
new_name | the new name for the constraint |
lsql | an optional reference to a list of strings to retrieve the SQL used to modify the constraint (only executed if the table is already in the database) |
CONSTRAINT-ERROR | if the old constraint does not exist in the table or if the new constraint name already exists |
AbstractIndex SqlUtil::AbstractTable::renameIndex | ( | string | old_name, |
string | new_name, | ||
reference | sql | ||
) |
renames an existing index; if the table is already known to be in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally
old_name | the current name of the index |
new_name | the new name for the index |
sql | an optional reference to a string to retrieve the SQL used to modify the table (only executed if the table is already in the database) |
INDEX-ERROR | if the old index does not exist in the table or if the new index name already exists |
softint SqlUtil::AbstractTable::rowCount | ( | ) |
returns the number of rows in the table
returns a hash of lists representing the columns and rows in the table that match the argument hahs
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically returns a hash of lists representing the columns and rows in the table that match the argument hahs
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically returns a hash representing the row in the table that matches the argument hash; if more than one row would be returned an exception is raised
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
DBI-SELECT-ROW-ERROR | more than 1 row retrieved from the server |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically returns a hash representing the row in the table that matches the argument hash; if more than one row would be returned an exception is raised
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
DBI-SELECT-ROW-ERROR | more than 1 row retrieved from the server |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically returns a list of hashes representing the rows in the table that match the argument hash
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
sql | an optional reference to a string to return the SQL generated for the select statement |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically returns a list of hashes representing the rows in the table that match the argument hash
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
OPTION-ERROR | invalid or unsupported select option |
SELECT-ERROR | 'offset' supplied without 'orderby' or 'limit' , 'orderby' with 'limit' and 'offset' does not match any unique constraint |
"offset"
is supplied and no "orderby"
is supplied, then if any primary key exists, the primary key columns will be used for the "orderby"
option automatically SqlUtil::AbstractTable::setDatasource | ( | AbstractDatasource | nds | ) |
changes the datasource for the table; if the inDb
flag is True, then it is set to False by calling this method
nds | the new datasource for the table |
creates the object from a table description hash
desc | a table description hash describing the table |
opt | 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 |
OPTION-ERROR | invalid or unsupported option passed |
DESCRIPTION-ERROR | invalid or unsupported description hash value passed |
SqlUtil::AbstractTable::truncate | ( | ) |
truncates all the table data; releases the transaction lock after executing
SqlUtil::AbstractTable::truncateNoCommit | ( | ) |
truncates all the table data without any transaction management
any SqlUtil::AbstractTable::tryExec | ( | string | sql | ) |
executes some SQL with optional arguments so that if an error occurs the current transaction state is not lost
Include any arguments in the parameter list after the sql argument
sql | the SQL to execute |
any SqlUtil::AbstractTable::tryExecArgs | ( | string | sql, |
*softlist | args | ||
) |
executes some SQL with optional arguments so that if an error occurs the current transaction state is not lost
sql | the SQL to execute |
args | the bind / placeholder or other arguments corresponding to the SQL string |
any SqlUtil::AbstractTable::tryExecRaw | ( | string | sql | ) |
executes some SQL so that if an error occurs the current transaction state is not lost
Include any arguments in the parameter list after the sql argument
sql | the SQL to execute |
updates rows in the table matching an optional condition and returns the count of rows updated; the transaction is committed if successful, if an error occurs then it is rolled back
set | the hash of values to set, key values are column names, hash values are the values to assign to those columns or update operators (see SQL Update Operator Functions) |
cond | a hash of conditions for the where clause; see Where Clauses for more information |
sql | an optional reference to a string to return the SQL generated for the select statement |
UPDATE-ERROR | the set hash is empty |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
updates rows in the table matching an optional condition and returns the count of rows updated; the transaction is committed if successful, if an error occurs then it is rolled back
set | the hash of values to set, key values are column names, hash values are the values to assign to those columns or update operators (see SQL Update Operator Functions) |
cond | a hash of conditions for the where clause; see Where Clauses for more information |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
UPDATE-ERROR | the set hash is empty |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
updates rows in the table matching an optional condition and returns the count of rows updated; no transaction management is performed with this method
set | the hash of values to set, key values are column names, hash values are the values to assign to those columns or update operators (see SQL Update Operator Functions) |
cond | a hash of conditions for the where clause; see Where Clauses for more information |
sql | an optional reference to a string to return the SQL generated for the select statement |
UPDATE-ERROR | the set hash is empty |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
updates rows in the table matching an optional condition and returns the count of rows updated; no transaction management is performed with this method
set | the hash of values to set, key values are column names, hash values are the values to assign to those columns or update operators (see SQL Update Operator Functions) |
cond | a hash of conditions for the where clause; see Where Clauses for more information |
opt | optional SQL data operation callback options; see AbstractTable::SqlDataCallbackOptions for more info |
UPDATE-ERROR | the set hash is empty |
WHERE-ERROR | unknown operator or invalid arguments given in the cond hash for the where clause |
int SqlUtil::AbstractTable::upsert | ( | hash | row, |
int | upsert_strategy = UpsertAuto |
||
) |
update or insert the data in the table according to the hash argument; the table must have a unique key to do this; the transaction is committed if successful, if an error occurs then it is rolled back
row | a hash representing the row to insert or update |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
*hash SqlUtil::AbstractTable::upsertFromIterator | ( | Qore::AbstractIterator | i, |
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; the transaction is committed if successful, if an error occurs then it is rolled back
i | the Qore::AbstractIterator argument that will provide the data to upsert or merge into the current table; the getValue() method of this object must return a hash giving row values (for example, the Qore::SQL::SQLStatement class is well-suited to be used here) |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.*hash SqlUtil::AbstractTable::upsertFromIteratorNoCommit | ( | Qore::AbstractIterator | i, |
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given iterator argument (whose getValue() method must return a hash giving row values) into the current table; no transaction management is performed with this method
i | the Qore::AbstractIterator argument that will provide the data to upsert or merge into the current table; the getValue() method of this object must return a hash giving row values (for example, the Qore::SQL::SQLStatement class is well-suited to be used here) |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options; note that this method ignores any "commit_block" option |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.*hash SqlUtil::AbstractTable::upsertFromSelect | ( | AbstractTable | t, |
*hash | sh, | ||
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given foreign table and select option hash into the current table; the transaction is committed if successful, if an error occurs then it is rolled back
The table argument does not need to be in the same database as the current table; it can also be in a different database server or a database server of a different type (you can use this method to upsert or merge data to or from any database supported by SqlUtil).
t | the table for the source data; this does not need to be in the same database as the target (the current table), nor does it need to be the same database type |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.*hash SqlUtil::AbstractTable::upsertFromSelect | ( | Table | t, |
*hash | sh, | ||
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given foreign table and select option hash into the current table; the transaction is committed if successful, if an error occurs then it is rolled back
The table argument does not need to be in the same database as the current table; it can also be in a different database server or a database server of a different type (you can use this method to upsert or merge data to or from any database supported by SqlUtil).
t | the table for the source data; this does not need to be in the same database as the target (the current table), nor does it need to be the same database type |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.*hash SqlUtil::AbstractTable::upsertFromSelectNoCommit | ( | AbstractTable | t, |
*hash | sh, | ||
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given foreign table and select option hash into the current table; no transaction management is performed with this method
The table argument does not need to be in the same database as the current table; it can also be in a different database server or a database server of a different type (you can use this method to upsert or merge data to or from any database supported by SqlUtil).
t | the table for the source data; this does not need to be in the same database as the target (the current table), nor does it need to be the same database type |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options; note that this method ignores any "commit_block" option |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.this method uses an SQLStatement object to pipeline the select data to the upsert code; to release the transaction lock acquired by the SQLStatement object, a commit() or rollback() action must be executed on the underlying datasource object as in the example above
*hash SqlUtil::AbstractTable::upsertFromSelectNoCommit | ( | Table | t, |
*hash | sh, | ||
int | upsert_strategy = AbstractTable::UpsertAuto , |
||
*hash | opt | ||
) |
this method upserts or merges data from the given foreign table and select option hash into the current table; no transaction management is performed with this method
The table argument does not need to be in the same database as the current table; it can also be in a different database server or a database server of a different type (you can use this method to upsert or merge data to or from any database supported by SqlUtil).
t | the table for the source data; this does not need to be in the same database as the target (the current table), nor does it need to be the same database type |
sh | a hash of conditions for the select statement; see select option hash for information about this argument |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
opt | a hash of options for the upsert operation; see SqlUtil::AbstractTable::UpsertOptions for common options; each driver can support additional driver-specific options; note that this method ignores any "commit_block" option |
"inserted"
: the number of rows inserted"verified"
: the number of rows updated unconditionally; note that this key is returned with all upsert strategy codes other than SqlUtil::AbstractTable::UpsertSelectFirst instead of "updated"
"updated"
: the number of rows updated; note that this key is only returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst, otherwise updated rows are reported as "verified"
since rows are updated unconditionally with other the upsert strategy codes"unchanged"
: the number of rows unchanged; this key can only be returned if upsert_strategy is SqlUtil::AbstractTable::UpsertSelectFirst or SqlUtil::AbstractTable::UpsertInsertOnly"deleted"
: the number of rows deleted; this can only be returned if upsert option delete_others
is TrueOPTION-ERROR | invalid or unsupported option |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
delete_others
is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation is only executed if delete_others
is True and is expensive for large data sets.this method uses an SQLStatement object to pipeline the select data to the upsert code; to release the transaction lock acquired by the SQLStatement object, a commit() or rollback() action must be executed on the underlying datasource object as in the example above
int SqlUtil::AbstractTable::upsertNoCommit | ( | hash | row, |
int | upsert_strategy = UpsertAuto |
||
) |
update or insert the data in the table according to the hash argument; the table must have a unique key to do this
row | a hash representing the row to insert or update |
upsert_strategy | see Upsert Strategy Codes for possible values for the upsert strategy |
COLUMN-ERROR | an unknown column was referenced in the hash to be inserted |
UPSERT-ERROR | no primary key, unique constraint, or unique index for upsert; not all columns of the unique constraint/index are used in the upsert statement |
const SqlUtil::AbstractTable::AdditionalColumnDescOptions |
additional column description keys valid when describing columns in a table description hash
the following keys are valid in a table description hash in addition to any AbstractTable::ColumnDescOptions:
const SqlUtil::AbstractTable::AlignTableOptions |
table alignment options
currently this option is a combination of SqlUtil::AbstractTable::TableCreationOptions and the following options:
column_map:
a hash for automatically renaming columns; if the source name (key) exists and the target name (value) does not exist, then the source column is automatically renamedindex_map:
a hash for automatically renaming indexes; if the source name (key) exists and the target name (value) does not exist, then the source index is automatically renamedconstraint_map:
a hash for automatically renaming constraints; if the source name (key) exists and the target name (value) does not exist, then the source constraint is automatically renamedtrigger_map:
a hash for automatically renaming triggers; if the source name (key) exists and the target name (value) does not exist, then the source trigger is automatically renameddb_table_cache:
(Tables) an optional table cache for maintaining tables in the database and foreign key relationships between tables const SqlUtil::AbstractTable::ColumnDescOptions |
Column description options.
this option is made up of the following keys:
qore_type:
(string) a qore type string that will be converted to a native DB type with some default conversionnative_type:
(string) the native database column type; if both native_type
and qore_type
are given then native_type
is usedsize:
(int) for data types requiring a size component, the size; for numeric columns this represents the precision for examplescale:
(int) for numeric data types, this value gives the scaledefault_value:
the default value for the columncomment:
(string) an optional comment for the columnnotnull:
if the column should have a "not null" constraint on it; if missing the default value is Falsedriver:
this key can optionally contain a hash keyed by driver name which contains a hash of values that will be added to the column description hash before processing; this way a column description hash can contain all the information required for the column including driver-specific options; any driver-specific options will overwrite values in the top level of the hash if there are duplicate hash keys, see below for an example const SqlUtil::AbstractTable::ConstraintOptions = IndexOptions |
default constraint options
currently this option is identical to SqlUtil::AbstractTable::IndexOptions
const SqlUtil::AbstractTable::ForeignConstraintOptions |
default foreign constraint options
The following keys can be set for this option:
table_cache:
(Tables) an optional table cache for maintaining cached tables and foreign key relationships between tables const SqlUtil::AbstractTable::IndexOptions |
default index options
const SqlUtil::AbstractTable::InsertOptions |
default insert option keys
In addition to any SqlDataCallbackOptions, the following keys can be set for this option:
info_callback:
see Insert Info Callbackcommit_block:
the number of changes made before an automatic commit is made for insert methods that perform commits const SqlUtil::AbstractTable::SelectOptions |
default select options
the possible keys for select options are as follows (all keys are optional):
"where"
clause will be builtconst SqlUtil::AbstractTable::SqlDataCallbackOptions |
generic SQL data operation callbacks
The following keys can be set for this option:
sqlarg_callback:
see SQL Operation Callback Closure or Call Reference const SqlUtil::AbstractTable::TableCreationOptions |
table creation options
currently this option is a combination of SqlUtil::AbstractTable::IndexOptions and AbstractDatabase::CreationOptions plus the following:
omit:
a list pf attributes to omit; possible values are: indexes
, foreign_constraints
, triggers
(see TableOmissionOptions) const SqlUtil::AbstractTable::TableDescriptionHashOptions |
Table description options.
this option is made up of the following keys:
columns:
(column description hash) a hash describing the columnprimary_key
: (primary key description hash) a hash describing the primary key for the tableindexes:
(index description hashes) a hash describing the indexes on the tabletriggers:
a hash of trigger information keyed by trigger name; the values are the trigger source code; since triggers are driver-dependent, a driver-independent table description would include trigger hashes under the drivers
key and the driver key name under thatforeign_constraints:
(foreign constraint hashes) a hash describing the foreign constraints on the tableunique_constraints:
(unique constraint hashes) a hash describing the unique constraints on the tabletable_cache:
(Tables) an optional table cache for maintaining cached tables and foreign key relationships between tablesconst SqlUtil::AbstractTable::TableOptions |
table options
The following keys can be set for this option:
native_case:
(bool) if True then objects will be returned in the case the database server returns them in even if the database server uses case-insensitive names; normally in this case SqlUtil will convert the names to lower-casetable_cache:
(Tables) an optional table cache for maintaining cached tables and foreign key relationships between tables const SqlUtil::AbstractTable::TriggerOptions = AbstractDatabase::CreationOptions |
default trigger options
currently this option is identical to AbstractDatabase::CreationOptions
const SqlUtil::AbstractTable::UpsertOptions |
default upsert option keys
The following keys can be set for this option:
info_callback:
see Upsert Info Callbackcommit_block:
the number of changes made before an automatic commit is made for upsert methods that perform commitsdelete_others:
if this option is True, then a hash of primary key values in the input data is built as the input data is iterated. After iterating, if the row count of the table and the input data matches, then nothing more is done, otherwise, every row of the table is iterated and compared to the primary key hash; if a row does not match a primary key value, then it is deleted. This operation allows tables to be completely synchronized by removing rows in the target table not present in the source table. This operation is expensive for large data sets. const SqlUtil::AbstractTable::UpsertResultDescriptionMap |
hash mapping upsert descriptions to codes
const SqlUtil::AbstractTable::UpsertResultMap |
hash mapping upsert results to a description