All Classes Namespaces Functions Variables Groups Pages
SqlUtil.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file SqlUtil.qm Qore user module for working with SQL data
/* SqlUtil.qm Copyright 2013 Qore Technologies, sro
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.9 or better
// requires the Util module
// don't use "$" signs for variables and class members, assume local variable scope
// require type definitions everywhere
// enable all warnings
/* Version History
* 2013-12-30 v1.1: David Nichols <david@qore.org>
+ see release notes below or in doxygen docs
* 2013-10-04 v1.0: David Nichols <david@qore.org>
+ the initial version of the SqlUtil module
*/
...
@endcode
@warning Oracle: using different comments in the same SQL can lead to new optimizer statement hard parsing.
@anchor select_option_hint
@par Select Option "hint"
In database query operations, various SQL implementations use hints as additions to the SQL standard that instruct the database engine on how to execute the query. For example, a hint may tell the engine to use as little memory as possible (even if the query will run slowly), or to use or not to use an index (even if the query optimizer would decide otherwise).
<b>Hint Example:</b>
@code
$table.selectRows( ("hint" : "full(t1)") );
@endcode
will produce select statement like this:
@code
select /*+ full(a) */ ...
@endcode
The string is taken as is and it's up to user to handle correct aliases in join functions etc.
@note Hints are platform dependent. Curently only Oracle and some versions of PostgreSQL hints are supported in Sqlutil module.
@warning Use hints only when you know what you are doing.
@anchor select_option_columns
@par Select Option "columns"
<b>Columns Example:</b>
@code
my list $columns = ("id", "name", "started", cop_as("warnings", "warning_count"), cop_as("errors", "error_count"));
my *list $rows = $table.selectRows(("columns": $columns, "where": ("type": "user")));
@endcode
By default, all columns are returned from a query; to limit the columns returned, or to perform column operations on the columns returned, use the \c "columns" option of the @ref select_option_hash "select option hash". \n\n
This option takes a list, each element of the list can be one of the following.\n\n
<b>A Simple String Giving a Column Name</b>\n
ex: \c "name"
@code
my *list $rows = $table.selectRows(("columns": ("id", "name", "started")));
@endcode \n
<b>A String in Dot Notation</b>\n
This format is for use with @ref select_option_join "joins"; ex: \c "q.name"
@code
my *list $rows = $table.selectRows(("columns": ("table.id", "t2.customer_name"), "join": join_inner($table2, "t2", ("id": "altid"))));
@endcode \n
<b>A Column Operation Specified by a Column Operator Function</b>\n
ex: <tt>cop_as("column_name", "column_alias")</tt> \n
See @ref sql_cop_funcs "column operator function" for more information on column operator functions
@code
my *list $rows = $table.selectRows(("columns": ("id", cop_as("warnings", "warning_count"), cop_as("errors", "error_count"))));
@endcode
For @ref sql_cop_funcs "column operator functions" taking a column name, either a string name or a name in dot notation is acceptable\n\n
<b>The Value \c "*", Meaning All Columns</b>\n
ex: \c "*"
@code
my *list $rows = $table.selectRows(("columns": "*"));
@endcode
This is the default if no \c "columns" key is included in the @ref select_option_hash "select option hash" \n\n
<b>An \c "*" in Dot Notation</b>\n
ex: \c "q.*"
@code
my *list $rows = $table.selectRows(("columns": ("table.id", "t2.*"), "join": join_inner($table2, "t2", ("id": "altid"))));
@endcode
@anchor select_option_where
@par Select Option "where"
<b>Where Example:</b>
@code
my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
@endcode
The hash value assigned to this key describes how the \c "where" clause in the query is built. Because the \c "where" clause logic is common to many SQL methods, this topic is covered in a separate section. See @ref where_clauses for a detailed description of the value of this key.
@anchor select_option_orderby
@par Select Option "orderby"
<b>Orderby Example:</b>
@code
my *list $rows = $table.selectRows(("where": ("account_type": "CUSTOMER"), "orderby": "created_date"));
@endcode
This option is a list of the following values:
- a simple string giving a column name; ex: \c "name"
- a string giving a table or table alias and a column name in dot notation (for use with @ref select_option_join "joins"); ex: \c "q.name"
@note
- By using the @ref select_option_offset "offset option" the results will be automatically ordered according to the primary key of the table
@anchor select_option_desc
@par Select Option "desc"
<b>Desc Example:</b>
@code
my *list $rows = $table.selectRows(("where": ("account_type": "CUSTOMER"), "orderby": "created_date", "desc": True));
@endcode
If the value of this key is @ref Qore::True "True" and results are ordered (either due to the @ref select_option_orderby "orderby option" or due to implicit ordering by the primary key due to the use of the @ref select_option_offset "offset option"), then results will be sorted in descending order.\n\n
Otherwise, ordered results are returned in ascending order by default.
@anchor select_option_limit
@par Select Option "limit"
<b>Limit Example:</b>
@code
my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
@endcode
This option will limit the number of rows returned.
@note
- This option is required if the @ref select_option_offset "offset option" is non-zero
- If this option is present and an @ref select_option_orderby "orderby option" is also present, then at least a subset of the @ref select_option_orderby "orderby" columns must correspond to a unique key of the table or an exception is raised
@anchor select_option_offset
@par Select Option "offset"
<b>Offset Example:</b>
@code
my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
@endcode
This option specifies the row number offset for the rows returned where the first row is at offset zero.
@note
- If this option is present, then either an @ref select_option_orderby "orderby option" must be present of which at least a subset of the @ref select_option_orderby "orderby" columns must correspond to a unique key of the table, or, if no @ref select_option_orderby "orderby option" is used, then the table must have a primary key which is used for the ordering instead.
- Additionally, this option requires the presence of the @ref select_option_limit "limit option", or an exception will be thrown.
@see @ref sql_paging
@anchor select_option_join
@par Select Option "join"
<b>Join Example:</b>
@code
my *list $rows = $table.selectRows(("columns": ("name", "version", "id", cop_as("st.value", "source"), cop_as("st.value", "offset")),
"join": join_left($function_instance_tags, "st", NOTHING, ("st.tag": "_source"))
+ join_left($function_instance_tags, "lt", NOTHING, ("st.tag": "_offset"))));
@endcode
To join multiple tables in a single query, use the \c "join" option. The \c "join" hash key should be assigned to a join description hash as returned by one of the @ref sql_jop_funcs or combined join description hash created by concatenating such values (see an example of this above).
@note the join columns do not need to be specified in the case that a foreign key in one table exists to the primary key of the other table; in this case this information is assumed for the join automatically
@see @ref joins for more examples
@anchor select_option_groupby
@par Select Option "groupby"
<b>Groupby Example:</b>
@code
my *list $rows = $table.selectRows(("columns": (cop_as(cop_max("service_type"), "type"), cop_count()), "groupby": "service_type"));
@endcode
The \c "groupby" option allows for aggregate SQL column operator functions to be used (ex: @ref cop_max(), cop_min()) in select statements.
The \c "groupby" hash key should be assigned to a list of column specifiers or a single column specifier. Column specifies for the \c "groupby"
key are strings giving column names, optionally in dot notation.
@anchor select_option_having
@par Select Option "having"
<b>Having Example:</b>
@code
my *list $rows = $table.selectRows(("columns": (cop_as(cop_max("service_type"), "type"), cop_count()), "groupby": "service_type", "having": ("service_type": (COP_COUNT, op_ge(100)))));
@endcode
The \c "having" option allows for query results with aggregate SQL column operator functions to be filtered by user-defined criteria.
The \c "having" hash key should be assigned to a hash where each key is a column specifier (optionally in dot notation) and the values are lists with two elements; the first element must be a @ref sql_cops "column operator code", and the second element is a column operator description normally provided by using a @ref sql_cop_funcs "column operator function" as in the above example.
@anchor select_option_superquery
@par Select Option "superquery"
<b>Superquery Example:</b>
@code
my *list $rows = $table.selectRows("columns": ("serviceid", "service_methodid", cop_as(cop_over(cop_max("service_methodid"), "serviceid"), "max_methodid")), "superquery": ("columns": ("serviceid", "service_methodid"), "where": ("max_methodid": op_ceq("service_methodid"))));
@endcode
The \c "superquery" option allows for the rest of the query arguments to define a subquery where as the hash arguments assigned to the \c "superquery" key define the select made from the subquery. In the example above, the \c "OVER" sql windowing function is used and then rows matching the \c "max_methodid)" result value are selected.\n\n
The above example results in an SQL command equivalent to the following:
@code
my *list $rows = $table.vselectRows("select serviceid,service_methodid from (select serviceid,service_methodid,max(service_methodid) over (partition by serviceid) as max_methodid from schema.service_methods) subquery where max_methodid = service_methodid");
@endcode
@note that MySQL does not support SQL windowing functions so the above example would fail on MySQL.
@subsection sql_paging Select With Paging
There is support for paging query results in the following methods:
- @ref SqlUtil::Table::getRowIterator()
- @ref SqlUtil::Table::getSelectSql()
- @ref SqlUtil::Table::select()
- @ref SqlUtil::Table::selectRows()
@note the above list also applies to the corresponding @ref SqlUtil::AbstractTable methods
Each of these methods takes a @ref select_option_hash "select option hash argument" that allows the \c "limit" and \c "offset" options to be specified to specify the data window for the results.
If the \c "offset" options is used, then an \c "orderby" option is required which must match some unique constraint or unique index on the table to guarantee the order of results, unless the table has a primary key, in which case the primary key will be used by default if no \c "orderby" option is supplied.
@par Example:
Select 100 rows starting at row 200 (the table's primary key will be used for the \c "orderby" option by default): \n
@code
my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
@endcode
As an illustration of the different SQL that is generated for different database types; for the above query, here is the SQL generated for Oracle:
@code
$ds.vselectRows("select * from (select /*+ first_rows(100) */ a.*, rownum rnum from (select * from schema.table where type = %v order by type) a where rownum <= %v) where rnum > %v", ("user", 300, 200));
@endcode
And for PostgreSQL:
@code
$ds.vselectRows("select * from public.table where type = %v order by type limit %v offset %v", ("user", 100, 200));
@endcode
@subsection check_matching_rows Check For At Least One Matching Row
Use the @ref SqlUtil::Table::findSingle() method to find at least one matching row:
@code
my *hash $h = $table.findSingle(("account_type": "CUSTOMER"));
if ($h)
printf("found 1 customer row: %y\n", $l[0]);
@endcode
Also it's possible to use the \c "limit" option to make an efficient check for at least one matching row as in the following example (which is functionally equivalent to the previous example):
@code
my *hash $h = $table.selectRow(("where": ("account_type": "CUSTOMER"), "limit": 1));
if ($h)
printf("found 1 customer row: %y\n", $l[0]);
@endcode
@section inserting_data Inserting Data into the Database
The following methods can be used to insert data into the database:
- @ref SqlUtil::Table::insert(): inserts a single row into a table and commits the transaction
- @ref SqlUtil::Table::insertNoCommit(): inserts a single row into a table without committing the transaction
- @ref SqlUtil::Table::insertFromSelect(): inserts data in a table based on a select statement created from the @ref select_option_hash "select option hash" argument and commits the transaction
- @ref SqlUtil::Table::insertFromSelectNoCommit(): inserts data in a table based on a select statement created from the @ref select_option_hash "select option hash" argument and without committing the transaction
@see @ref sql_upsert for information about upserting or merging data
@subsection inserting_data_explicitly Inserting Data Explicitly
@par Example:
@code
$table.insert(("id": $id, "name": $name, "created": now_us()));
@endcode
Data can be explicitly inserted into the database with immediate values with @ref SqlUtil::Table::insert() and @ref SqlUtil::Table::insertNoCommit() as in the above example.
@subsection inserting_data_from_select Inserting Data From a Select Statement
@par Example:
@code
my int $rows = $table.insertFromSelect(("id", "name", "created"), $source_table, (("columns": ("cid", "fullname", "created"), "where": ("type": "CUSTOMER"))));
@endcode
Data can be inserted into the database based on the results of a select statement with @ref SqlUtil::Table::insertFromSelect() and @ref SqlUtil::Table::insertFromSelectNoCommit() as in the above example.
The example above would generate a %Qore SQL command like the following:
@code
return $ds.vexec("insert into schema.table (id,name,created) select cid,fullname,created from schema.source_table where type = %v", ("CUSTOMER"));
@endcode
The return value of these methods is the number of rows inserted. See @ref select_option_hash "select option hash" for more information about how to form the select criteria in these methods.
@subsection inserting_data_from_iterator Inserting Data from an Iterator Source
To insert data from an iterator source (such as an @ref Qore::SQL::SQLStatement object), call @ref SqlUtil::Table::insertFromIterator() or @ref SqlUtil::Table::insertFromIteratorNoCommit() as in the following example:
@par Example:
@code
# get the rows to be inserted
my list $l = get_table_rows();
# insert the data and commit after every 5000 rows
$table.insertFromIterator($l.iterator(), ("commit_block": 5000));
@endcode
The iterator given to the @ref SqlUtil::Table::insertFromIterator() or @ref SqlUtil::Table::insertFromIteratorNoCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "hash".
@note the @ref SqlUtil::AbstractTable::InsertOptions "insert option" \c "commit_block" can be used to insert a large amount of data in pieces in order to avoid overwhelming the database server's rollback cache
@section updating_data Updating Data
The following methods can be used to update data:
- @ref SqlUtil::Table::update(): updates a single row and commits the transaction
- @ref SqlUtil::Table::updateNoCommit(): updates a single row and does not commit the transaction
@par Example:
@code
my int $rows_updated = t.update(("permission_type": uop_append("-migrated", uop_lower())));
@endcode
The example above generates a %Qore SQL command like the following on Oracle and PostgreSQL for example:
@code
return $ds.vexec("update schema.table set permission_type = lower(permission_type) || '-migrated');
@endcode
And the following on MySQL:
@code
return $ds.vexec("update schema.table set permission_type = concat(lower(permission_type), '-migrated'));
@endcode
@section deleting_data Deleting Data
The following methods can be used to dekete data:
- @ref SqlUtil::Table::del(): updates the table based on a @ref where_clauses "where clause" and commits the transaction
- @ref SqlUtil::Table::delNoCommit(): updates the table based on a @ref where_clauses "where clause" and does not commit the transaction
- @ref SqlUtil::Table::truncate(): truncates the table and commits the transaction releasing the transaction lock on the underlying datasource object
- @ref SqlUtil::Table::truncateNoCommit(): truncates the table and does not commit the transaction
@par Example:
@code
my int $dcnt = $table.del(("record_type": "OLD-CUSTOMER"));
@endcode
The above example would generate a %Qore SQL command like the following:
@code
return $ds.vexec("delete from schema.table where record_type = %v", ("OLD-CUSTOMER"));
@endcode
The @ref SqlUtil::Table::del() and @ref SqlUtil::Table::delNoCommit() methods can be used to delete data from the database.
See @ref where_clauses for information about specifying the criteria for the rows to be deleted.
@section joins Joining Tables
Joining tables is made by providing a join specification to the @ref select_option_join "join select option" in
a @ref select_option_hash "select option hash" as in the following example:
@code
my *list $rows = $table.selectRows(("columns": ("table.id", "t2.customer_name"), "join": join_inner($table2, "t2", ("id": "altid"))));
@endcode
In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt>.
Joins on multiple tables are performed by combining the results of @ref sql_op_funcs "join functions" with the @ref plus_operator "+ operator"
as follows:
@code
my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner($table3, "t3")));
@endcode
In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt> and with \a table3 on an
automatically detected primary key to foreign key relationship between the two tables.
Joins are by default made with the primary table; to join with another join table, then give the alias for the table as the first
argument to the @ref sql_op_funcs "join function" as in the following example:
@code
my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner("t2", $table3, "t3")));
@endcode
In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt> and \a table2 (aliased as \c t2) is joined
with \a table3 (aliased as \c t3) on an automatically detected primary key to foreign key relationship between the two tables.
@see @ref select_option_join "join select option"
@section where_clauses Where Clauses
Several methods accept a hash of conditions to build a \c "where" clause to restrict the rows that are operated on or returned; for example:
- @ref SqlUtil::Table::del()
- @ref SqlUtil::Table::delNoCommit()
- @ref SqlUtil::Table::findAll()
- @ref SqlUtil::Table::findSingle()
- @ref SqlUtil::Table::getRowIterator()
- @ref SqlUtil::Table::getSelectSql()
- @ref SqlUtil::Table::insertFromSelect()
- @ref SqlUtil::Table::insertFromSelectNoCommit()
- @ref SqlUtil::Table::select()
- @ref SqlUtil::Table::selectRow()
- @ref SqlUtil::Table::selectRows()
- @ref SqlUtil::Table::update()
- @ref SqlUtil::Table::updateNoCommit()
- @ref SqlUtil::Table::upsertFromSelect()
- @ref SqlUtil::Table::upsertFromSelectNoCommit()
@note the above list also applies to the corresponding @ref SqlUtil::AbstractTable methods
The where clause or condition hash is made of keys signifying the column names, and either a direct value meaning that the column value has to match exactly, or SQL operators can be given by using the appropriate operator function as the key value. Each member of the where hash translates to an expression that is combined with \c "AND" in the SQL query; to combine expressions with \c "OR", then use a list of @ref select_option_hash "select option hashes", which will combine each @ref select_option_hash "select option hash" with \c "OR" as in @ref where_list "this example".
The where condition hash has the following format:
- each key gives a column name or a table/alias with column name in dot notation
- the values are either direct values, meaning that the equality operator (\c "=") is used, or a @ref sql_op_funcs "SQL operator function" for operators in the where clause
@note To reference a column more than once in a where clause, prefix the column specification with a unique number and a colon as in the following example: @code my hash $w = ("0:created": op_ge($mindate), "1:created": op_lt($maxdate)); @endcode
See @ref sql_op_funcs for a list of operator functions.
@par Where Hash Example:
@code
my hash $w = (
"name": "Smith",
"account_type": op_like("%CUSTOMER%"),
"id": op_ge(500),
);
@endcode \n
The preceding example results in a where clause equivalent to: \c "name = 'Smith' and type like '%CUSTOMER%' and id >= 500", except
that bind by value is used, so, if used in a context like the following:
@code
my Table $t($ds, "table");
my *hash $qh = $t.select(("where": $w));
@endcode \n
the complete query would look instead as follows:
@code
$ds.vselect("select * from table where name = %v and account_type like %v and id >= %v", ("Smith", "%CUSTOMER%", 500));
@endcode
@anchor where_list
@par Where List Example:
@code
my hash $w1 = (
"name": "Smith",
"account_type": op_like("%CUSTOMER%"),
"id": op_ge(500),
);
my hash $w2 = (
"name": "Jones",
"account_type": op_like("%VENDOR%"),
"id": op_ge(2500),
);
my Table $t($ds, "table");
my *hash $qh = $t.select(("where": ($w1, $w2)));
@endcode \n
the complete query would look instead as follows:
@code
$ds.vselect("select * from table where (name = %v and account_type like %v and id >= %v) or (name = %v and account_type like %v and id >= %v)", ("Smith", "%CUSTOMER%", 500, "Jones", "%VENDOR%", 2500));
@endcode
@par Code Examples:
Find a single row in the table where the \c "permission_type" column is a value between \c "US" and \c "UX":\n
@code
my *hash $row = $table.findSingle(("permission_type": op_between("US", "UX")));
@endcode
resulting in an internal SQL command that looks as follows (depending on the database):
@code
my *hash $row = $ds.vselectRow("select * from table where permission_type between %v and %v limit %v", ("US", "UX", 1));
@endcode \n
Delete all rows in the table where the \c "name" column is like \c "%Smith%":\n
@code
my int $row_count = $table.del(("name": op_like("%Smith%")));
@endcode
resulting in an internal SQL command that looks as follows:
@code
$ds.vexec("delete from table where name like %v", ("%Smith%"));
@endcode \n
Find all rows where \c "id" is greater than \c 100 and \c "created" is after \c 2013-03-01:\n
@code
my *list $rows = $table.findAll(("id": op_gt(100), "created": op_gt(2013-03-01)));
@endcode
resulting in an internal SQL command that looks as follows:
@code
$ds.vexec("select * from table where id > %v and created > %v", (100, 2013-03-01));
@endcode \n
@section sql_upsert Upserting or Merging Data
This module offers a high-level api for "upserting" or merging data from one table into another table through the following methods:
- @ref SqlUtil::Table::upsert()
- @ref SqlUtil::Table::upsertNoCommit()
- @ref SqlUtil::Table::getUpsertClosure()
- @ref SqlUtil::Table::getUpsertClosureWithValidation()
- @ref SqlUtil::Table::upsertFromIterator()
- @ref SqlUtil::Table::upsertFromIteratorNoCommit()
- @ref SqlUtil::Table::upsertFromSelect()
- @ref SqlUtil::Table::upsertFromSelectNoCommit()
@subsection sql_upsert_single Upsert a Single Row
@par Example:
@code
$table.upsert(("id": $id, "name": $name, "account_type": $account_type));
@endcode
To upsert or merge a single row in the database, call @ref SqlUtil::Table::upsert() or @ref SqlUtil::Table::upsertNoCommit() with the
single row to be upserted or merged as a hash as in the preceding example.
@subsection sql_upsert_many Upserting Many Rows Using An Upsert Closure
To upsert or merge many rows by using an upsert closure, call @ref SqlUtil::Table::getUpsertClosure() or @ref SqlUtil::Table::getUpsertClosureWithValidation() and provide an example row as an argument to acquire a closure that will be executed on the rest of the rows as in the following example.
@par Simple Example:
@code
# get the rows to be inserted
my list $l = get_table_rows();
if ($l) {
my code $upsert = $table.getUpsertClosure($l[0]);
on_success $ds.commit();
on_error $ds.rollback();
# loop through the reference data rows
map $upsert($1), $l;
}
@endcode
@par Complex Example With Callbacks:
@code
# set the upsert strategy depending on the use case
my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
# hash summarizing changes
my hash $sh;
# get the rows to be inserted
my list $l = get_table_rows();
if ($l) {
# get the upsert closure to use based on the first row to be inserted
my code $upsert = $table.getUpsertClosure($l[0], $upsert_strategy);
on_success $ds.commit();
on_error $ds.rollback();
# loop through the reference data rows
foreach my hash $h in ($l) {
my int $code = $upsert($h);
if ($code == AbstractTable::UR_Unchanged)
continue;
my string $change = AbstractTable::UpsertResultMap{$code};
++$sh{$change};
if (!$verbose) {
printf(".");
flush();
}
else if ($verbose > 1)
printf("*** reference data %s: %y: %s\n", $table.getName(), $h, $change);
}
# show table summary
if ($sh)
printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
else
printf("*** reference data %s: OK\n", $table.getName());
}
@endcode
@subsection sql_upsert_from_iterator Upserting Many Rows from an Iterator Source
To upsert or merge many rows from an iterator source (such as an @ref Qore::SQL::SQLStatement object), call @ref SqlUtil::Table::upsertFromIterator() or @ref SqlUtil::Table::upsertFromIteratorNoCommit() as in the following example:
@par Simple Example:
@code
# get the rows to be inserted
my list $l = get_table_rows();
$table.upsertFromIterator($l.iterator());
@endcode
@par Complex Example With Callbacks:
@code
# set the upsert strategy depending on the use case
my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
# get the rows to be inserted
my list $l = get_table_rows();
my code $callback = sub (string $table_name, hash $row, int $result) {
if ($result == AbstractTable::UR_Unchanged)
return;
my string $change = AbstractTable::UpsertResultMap{$result};
if ($verbose)
printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
};
my hash $sh = $table.upsertFromIterator($l.iterator(), $upsert_strategy, False, ("info_callback": $callback, "commit_block": 5000));
if ($sh)
printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
else
printf("*** reference data %s: OK\n", $table.getName());
@endcode
The iterator given to the @ref SqlUtil::Table::upsertFromIterator() or @ref SqlUtil::Table::upsertFromIteratorNoCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "hash".
@note the @ref SqlUtil::AbstractTable::UpsertOptions "upsert option" \c "commit_block" can be used to insert a large amount of data in pieces in order to avoid overwhelming the database server's rollback cache
@subsection sql_upsert_from_select Upserting Many Rows from a Select Statement
To upsert or merge many rows from a select statement, use @ref SqlUtil::Table::upsertFromSelect() or @ref SqlUtil::Table::upsertFromSelectNoCommit() as in the following example:
@par Simple Example:
@code
$table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")));
@endcode
@par Complex Example With Callbacks:
@code
# set the upsert strategy depending on the use case
my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
my code $callback = sub (string $table_name, hash $row, int $result) {
if ($result == AbstractTable::UR_Unchanged)
return;
my string $change = AbstractTable::UpsertResultMap{$result};
if ($verbose)
printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
};
my hash $sh = $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), $upsert_strategy, False, ("info_callback": $callback, "commit_block": 5000));
if ($sh)
printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
else
printf("*** reference data %s: OK\n", $table.getName());
@endcode
The source table does not have to be in the same database or even of the same database type (ie you can upsert to and from any database type supported by SqlUtil).
@note the @ref SqlUtil::AbstractTable::UpsertOptions "upsert option" \c "commit_block" can be used to insert a large amount of data in pieces in order to avoid overwhelming the database server's rollback cache
@subsection sql_upsert_with_delete Upserting Many Rows and Deleting Unwanted Rows
Call any of the batch upsert methods with @ref SqlUtil::AbstractTable::UpsertOptions "upsert option" \c delete_others set to @ref Qore::True "True" to perform a batch upsert / merge operation on a table, and then scan the table and delete any unwanted rows. If there are no rows to be deleted, these calls have very similar performance to the batch upsert method calls without any deletions, however, if there are rows to be deleted, then the entire source table must be iterated to compare each row to valid data to delete the rows that do not belong. Therefore for large tables this can be an expensive operation.
The only difference in the following examples and the preceding ones is that @ref SqlUtil::AbstractTable::UpsertOptions "upsert option" \c delete_others is @ref Qore::True "True" in these examples.
@par Simple Example:
@code
# get the rows to be inserted
my list $l = get_table_rows();
$table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), AbstractTable::UpsertAuto, ("delete_others": True, "commit_block": 5000));
@endcode
@par Complex Example With Callbacks:
@code
# set the upsert strategy depending on the use case
my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
# get the rows to be inserted
my list $l = get_table_rows();
my code $callback = sub (string $table_name, hash $row, int $result) {
if ($result == AbstractTable::UR_Unchanged)
return;
my string $change = AbstractTable::UpsertResultMap{$result};
if ($verbose)
printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
};
my hash $sh = $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), $upsert_strategy, ("delete_others": True, "info_callback": $callback, "commit_block": 5000));
if ($sh)
printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
else
printf("*** reference data %s: OK\n", $table.getName());
@endcode
@note the @ref SqlUtil::AbstractTable::UpsertOptions "upsert option" \c "commit_block" can be used to insert a large amount of data in pieces in order to avoid overwhelming the database server's rollback cache
@subsection sql_upsert_strategies Upsert Strategies
The approach used is based on one of the following strategies (see @ref upsert_options):
- @ref SqlUtil::AbstractTable::UpsertAuto "AbstractTable::UpsertAuto": if the target table is empty, then @ref SqlUtil::AbstractTable::UpsertInsertFirst is used, otherwise @ref SqlUtil::AbstractTable::UpsertUpdateFirst is used
- @ref SqlUtil::AbstractTable::UpsertInsertFirst "AbstractTable::UpsertInsertFirst": first an insert will be attempted, if it fails due to a duplicate key, then an update will be made; this strategy should be used if more inserts will be made than updates
- @ref SqlUtil::AbstractTable::UpsertUpdateFirst "AbstractTable::UpsertUpdateFirst": first an update will be attempted, if it fails due to missing data, then an insert is performed; this strategy should be used if more updates will be made then inserts
- @ref SqlUtil::AbstractTable::UpsertSelectFirst "AbstractTable::UpsertSelectFirst": first a select is made on the unique key, if the data to be updated is equal, nothing is done and @ref upsert_results "upsert result" @ref SqlUtil::AbstractTable::UR_Unchanged is returned
- @ref SqlUtil::AbstractTable::UpsertInsertOnly "AbstractTable::UpsertInsertOnly": insert if the row doesn't exist, otherwise do nothing and @ref upsert_results "upsert result" @ref SqlUtil::AbstractTable::UR_Unchanged is returned
@note @ref SqlUtil::AbstractTable::UpsertSelectFirst "AbstractTable::UpsertSelectFirst" is the only upsert strategy that can return @ref SqlUtil::AbstractTable::UR_Updated; the @ref SqlUtil::AbstractTable::UpsertSelectFirst "AbstractTable::UpsertSelectFirst" strategy should be used when verbose reporting is required, particularly if it's necessary to report the actual number of changed rows.
*/
namespace SqlUtil {
/* @defgroup DBFeaturesConstants DB Features Constants
These constants can be used as a lookup values in AbstractDatabase::features() method.
*/
const DB_FUNCTIONS = "functions";
const DB_MVIEWS = "materialized views";
const DB_PACKAGES = "packages";
const DB_PROCEDURES = "procedures";
const DB_SEQUENCES = "sequences";
const DB_TABLES = "tables";
const DB_TYPES = "named types";
const DB_VIEWS = "views";
/* @defgroup SqlTypeConstants SQL Type Constants
These constants can be used for the \c "qore_type" values when creating columns to specify additional SQL column types
*/
const VARCHAR = "string";
const NUMERIC = "number";
const CHAR = "char";
const BLOB = "blob";
const CLOB = "clob";
const SZ_NONE = 0;
const SZ_MAND = 1;
const SZ_OPT = 2;
const SZ_NUM = 3;
const COP_AS = "as";
const COP_PREPEND = "prepend";
const COP_APPEND = "append";
const COP_VALUE = "value";
const COP_UPPER = "upper";
const COP_LOWER = "lower";
const COP_DISTINCT = "distinct";
const COP_MIN = "min";
const COP_MAX = "max";
const COP_AVG = "avg";
const COP_COUNT = "count";
const COP_OVER = "over";
const COP_MINUS = "minus";
const COP_PLUS = "plus";
const COP_DIVIDE = "divide";
const COP_MULTIPLY = "multiply";
const COP_YEAR = "year";
const COP_YEAR_MONTH = "year_month";
const COP_YEAR_DAY = "year_day";
const COP_YEAR_HOUR = "year_hour";
const DefaultCopMap = (
COP_AS: (
"arg": Type::String,
"code": string (string cve, string arg) {
return sprintf("%s as %s", cve, arg);
},
),
COP_PREPEND: (
"arg": Type::String,
"sqlvalue": True,
"code": string (string cve, string arg) {
return sprintf("%s||%s", arg, cve);
},
),
COP_APPEND: (
"arg": Type::String,
"sqlvalue": True,
"code": string (string cve, string arg) {
return sprintf("%s||%s", cve, arg);
},
),
COP_VALUE: (
"sqlvalue": True,
"nocolumn": True,
"code": string (*string cve, any arg) {
return arg;
},
),
COP_UPPER: (
"code": string (string cve, any arg) {
return sprintf("upper(%s)", cve);
},
),
COP_LOWER: (
"code": string (string cve, any arg) {
return sprintf("lower(%s)", cve);
},
),
COP_DISTINCT: (
"code": string (string cve, any arg) {
return sprintf("distinct %s", cve);
},
),
COP_MIN: (
"code": string (string cve, any arg) {
return sprintf("min(%s)", cve);
},
"group": True,
),
COP_MAX: (
"code": string (string cve, any arg) {
return sprintf("max(%s)", cve);
},
"group": True,
),
COP_AVG: (
"code": string (string cve, any arg) {
return sprintf("avg(%s)", cve);
},
"group": True,
),
COP_COUNT: (
"nocolumn": True,
"code": string (*string cve, any arg) {
return sprintf("count(%s)", cve ? cve : "1");
},
),
COP_MINUS: (
"argcolumn": True,
"code": string (string arg1, string arg2) {
return sprintf("%s - %s", arg1, arg2);
},
),
COP_PLUS: (
"argcolumn": True,
"code": string (string arg1, string arg2) {
return sprintf("%s + %s", arg1, arg2);
},
),
COP_DIVIDE: (
"argcolumn": True,
"code": string (string arg1, string arg2) {
return sprintf("%s / %s", arg1, arg2);
},
),
COP_MULTIPLY: (
"argcolumn": True,
"code": string (string arg1, string arg2) {
return sprintf("%s * %s", arg1, arg2);
},
),
);
hash make_cop(string cop, any column, any arg);
hash cop_as(any column, string arg);
hash cop_prepend(any column, string arg);
hash cop_append(any column, string arg);
hash cop_value(any arg);
hash cop_upper(any column);
hash cop_lower(any column);
hash cop_distinct(any column);
hash cop_min(any column);
hash cop_max(any column);
hash cop_avg(any column);
hash cop_count(string column = "");
hash cop_over(any column, string arg);
hash cop_minus(any column1, any column2);
hash cop_plus(any column1, any column2);
hash cop_divide(any column1, any column2);
hash cop_multiply(any column1, any column2);
hash cop_year(any column);
hash cop_year_month(any column);
hash cop_year_day(any column);
hash cop_year_hour(any column);
const DefaultUopMap = (
COP_PREPEND: True,
COP_APPEND: True,
COP_UPPER: True,
COP_LOWER: True,
);
hash make_uop(string uop, any arg, *hash nest);
hash uop_prepend(string arg, *hash nest);
hash uop_append(string arg, *hash nest);
hash uop_upper(*hash nest);
hash uop_lower(*hash nest);
const JOP_INNER = "inner";
const JOP_LEFT = "left";
const JOP_RIGHT = "right";
const JopMap = (
JOP_INNER: "inner",
JOP_LEFT: "left outer",
JOP_RIGHT: "right outer",
);
hash make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt);
hash join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_inner(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_inner(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_inner(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_left(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_left(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_left(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_right(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_right(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
hash join_right(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
const OP_LIKE = "like";
const OP_LT = "<";
const OP_LE = "<=";
const OP_GT = ">";
const OP_GE = ">=";
const OP_NE = "!=";
const OP_EQ = "=";
const OP_CLT = "C<";
const OP_CLE = "C<=";
const OP_CGT = "C>";
const OP_CGE = "C>=";
const OP_CNE = "C!=";
const OP_CEQ = "C=";
const OP_BETWEEN = "between";
const OP_IN = "in";
const OP_NOT = "not";
const DefaultOpMap = (
OP_LIKE: (
"code": string (object t, string cn, any arg, reference args) {
args += arg;
return sprintf("%s like %v", cn);
},
),
OP_LT: (
"code": string (object t, string cn, any arg, reference args) {
args += arg;
return sprintf("%s < %v", cn);
},
),
OP_LE: (
"code": string (object t, string cn, any arg, reference args) {
args += arg;
return sprintf("%s <= %v", cn);
},
),
OP_GT: (
"code": string (object t, string cn, any arg, reference args) {
args += arg;
return sprintf("%s > %v", cn);
},
),
OP_GE: (
"code": string (object t, string cn, any arg, reference args) {
args += arg;
return sprintf("%s >= %v", cn);
},
),
OP_NE: (
"code": string (object t, string cn, any arg, reference args) {
if (arg === NULL || !exists arg)
return sprintf("%s is not null", cn);
args += arg;
return sprintf("%s != %v", cn);
},
),
OP_EQ: (
"code": string (object t, string cn, any arg, reference args) {
if (arg === NULL || !exists arg)
return sprintf("%s is null", cn);
args += arg;
return sprintf("%s = %v", cn);
},
),
OP_BETWEEN: (
"code": string (object t, string cn, any arg, reference args) {
args += arg[0];
args += arg[1];
return sprintf("%s between %v and %v", cn);
},
),
OP_IN: (
"code": string (object t, string cn, any arg, reference args) {
*string ins = (foldl $1 + "," + $2, (map t.getSqlValue($1), arg));
return ins ? sprintf("%s in (%s)", cn, ins) : "1 != 1";
},
),
OP_NOT: (
"recursive": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("not (%s)", cn);
},
),
OP_CLT: (
"argcolumn": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("%s < %s", cn, arg);
},
),
OP_CLE: (
"argcolumn": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("%s <= %s", cn, arg);
},
),
OP_CGT: (
"argcolumn": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("%s > %s", cn, arg);
},
),
OP_CGE: (
"argcolumn": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("%s >= %s", cn, arg);
},
),
OP_CNE: (
"argcolumn": True,
"code": string (object t, string cn, any arg, reference args) {
return sprintf("%s != %s", cn, arg);
},
),
OP_CEQ: (
"argcolumn": True,
"code": string (object t, string cn, string arg, reference args) {
return sprintf("%s = %s", cn, arg);
},
),
);
hash make_op(string op, any arg);
hash op_like(string str);
hash op_lt(any arg);
hash op_le(any arg);
hash op_gt(any arg);
hash op_ge(any arg);
hash op_ne(any arg);
hash op_eq(any arg);
hash op_between(any l, any r);
hash op_in();
hash op_in(list args);
hash op_not(hash arg);
hash op_clt(string arg);
hash op_cle(string arg);
hash op_cgt(string arg);
hash op_cge(string arg);
hash op_cne(string arg);
hash op_ceq(string arg);
class AbstractHashContainer {
public:
private:
public:
private :
*hash h;
public:
constructor(*hash nh);
copy(AbstractHashContainer old);
any memberGate(string k);
clear();
abstract any take(string k);
renameKey(string old_name, string new_name);
*hash getHash();
bool matchKeys(hash h1);
bool matchKeys(list l);
bool matchKeys(AbstractHashContainer c);
bool partialMatchKeys(hash h1);
bool partialMatchKeys(list l);
bool partialMatchKeys(AbstractHashContainer c);
bool val();
list keys();
list values();
Qore::AbstractIterator iterator();
Qore::AbstractIterator keyIterator();
Qore::AbstractIterator pairIterator();
bool empty();
int size();
bool hasKey(string k);
bool hasKeyValue(string k);
*string firstKey();
*string lastKey();
abstract string getElementName();
};
class AbstractListContainer {
public:
private:
public:
private :
softlist l;
public:
constructor(softlist nl);
abstract any get(softint i);
add(any val);
any take(int i);
list getList();
bool val();
Qore::ListIterator iterator();
bool empty();
int size();
abstract string getElementName();
private checkIndex(int i);
};
class Tables : public AbstractHashContainer {
public:
constructor();
constructor(AbstractDatasource ds, hash tables, *hash opt);
constructor(AbstractDatasource ds);
add(string k, Table val);
add(string k, AbstractTable val);
add(Table val);
add(AbstractTable val);
AbstractTable take(string k);
populate(AbstractDatasource ds, hash tables, *hash opt);
populate(AbstractDatasource ds);
*list getDropAllForeignConstraintsOnTableSql(string name, *hash opt);
AbstractTable memberGate(string k);
string getElementName();
*AbstractTable getIfExists(AbstractDatasource ds, string name);
AbstractTable get(AbstractDatasource ds, string name);
*string getRenameTableIfExistsSql(string old_name, string new_name, *hash opts);
bool tableRenamed(string old_name, string new_name, string old_sql_name);
private tableRenamedIntern(string old_name, string new_name, string oldsn);
*string getDropConstraintIfExistsSql(string tname, string cname, *hash opts);
list getCreateList();
Qore::AbstractIterator createIterator();
list getDropList();
Qore::AbstractIterator dropIterator();
private getDependencies(reference tdh, reference sdh, *reference th);
};
class Columns : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractColumn val);
AbstractColumn take(string k);
AbstractColumn memberGate(string k);
Columns subset(softlist l);
string getElementName();
bool equal(Columns cols);
};
class AbstractColumn {
public:
public :
string name;
string native_type;
*string qore_type;
int size;
bool nullable;
*string def_val;
*string comment;
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string c);
string getNativeTypeString();
string getCreateSql();
abstract list getCreateSql(AbstractTable t);
string getDropSql(string table_name);
list getModifySql(AbstractTable t, AbstractColumn c, *hash opt);
abstract string getRenameSql(AbstractTable t, string new_name);
bool equal(AbstractColumn c);
private abstract bool equalImpl(AbstractColumn c);
private abstract list getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash opt);
};
class NumericColumnInfo {
public:
public :
int scale;
public:
constructor(softint n_scale = 0);
string getNativeTypeString(string native_type, int precision);
};
class Indexes : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractIndex val);
*AbstractIndex findEqual(AbstractIndex ix);
AbstractIndex take(string k);
AbstractIndex memberGate(string k);
string getElementName();
};
class AbstractIndex {
public:
public :
string name;
bool unique;
Columns columns;
public:
private :
*AbstractUniqueConstraint constraint;
public:
constructor(string n, bool u, hash c);
string getName();
bool hasColumn(string cname);
abstract string getCreateSql(string table_name, *hash opt);
string getDropSql(string table_name);
bool equal(AbstractIndex ix);
bool equalExceptName(AbstractIndex ix);
abstract bool equalImpl(AbstractIndex ix);
abstract string getRenameSql(string table_name, string new_name);
setSupportingConstraint(AbstractUniqueConstraint c);
setSupportingConstraint();
*AbstractUniqueConstraint getSupportingConstraint();
list getRecreateSql(AbstractDatasource ds, string table_name, *hash opt);
};
class Constraints : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractConstraint val);
AbstractConstraint take(string k);
*AbstractUniqueConstraint findEqualUniqueConstraint(AbstractUniqueConstraint uk);
AbstractConstraint memberGate(string k);
string getElementName();
};
class AbstractConstraint {
public:
private:
public:
private :
string name;
public:
constructor(string n);
string getName();
rename(string n);
abstract string getCreateSql(string table_name, *hash opt);
string getDropSql(string table_name);
abstract list getRenameSql(string table_name, string new_name);
string getDisableSql(string table_name);
string getEnableSql(string table_name, *hash opt);
bool equal(AbstractConstraint c);
private abstract bool equalImpl(AbstractConstraint c);
abstract bool setIndexBase(string ix);
abstract clearIndex();
bool hasColumn(string cname);
};
class AbstractCheckConstraint : public AbstractConstraint {
public:
public :
string src;
public:
constructor(string n, string n_src);
private bool equalImpl(AbstractConstraint c);
bool setIndexBase(string ix);
clearIndex();
};
class AbstractUniqueConstraint : public AbstractConstraint,public Columns {
public:
private :
hash sourceConstraints;
*string index;
public:
constructor(string n, *hash c, *string n_index);
abstract string getCreateSql(string table_name, *hash opts);
private bool equalImpl(AbstractConstraint c);
Qore::AbstractIterator getSourceConstraintIterator();
hash getDisableReenableSql(AbstractDatasource ds, string table_name, *hash opts);
findMatchingIndex(*Indexes indexes);
addSourceConstraint(string tname, AbstractForeignConstraint fk);
removeSourceConstraint(string tname, list cols);
renameSourceConstraintTable(string old_name, string new_name);
bool hasColumn(string cname);
*string getIndex();
};
class AbstractPrimaryKey : public AbstractUniqueConstraint {
public:
constructor();
constructor(string n, *hash c);
};
class ForeignConstraints : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractForeignConstraint val);
AbstractForeignConstraint take(string k);
*AbstractForeignConstraint findEqual(AbstractForeignConstraint fk);
AbstractForeignConstraint memberGate(string k);
*hash findConstraintOn(string table, softlist cols);
string getElementName();
};
class ForeignConstraintTarget {
public:
public :
string table;
Columns columns;
public:
constructor(string t, Columns c);
bool equal(ForeignConstraintTarget targ);
};
class AbstractForeignConstraint : public AbstractConstraint {
public:
public :
Columns columns;
ForeignConstraintTarget target;
public:
constructor(string n, Columns c, ForeignConstraintTarget t);
private bool equalImpl(AbstractConstraint con);
bool hasColumn(string cname);
bool setIndexBase(string ix);
clearIndex();
};
class AbstractSequence {
public:
public :
string name;
number start;
number increment;
*number max;
public:
constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_max);
abstract string getCreateSql(*hash opt);
string getDropSql();
abstract string getRenameSql(string new_name);
};
class AbstractView {
public:
public :
// ! potential object schema
*string schema;
string name;
string src;
bool updatable;
public:
constructor(string n_name, string n_src);
abstract string getCreateSql(*hash opt);
string getDropSql();
abstract softlist getRenameSql(string new_name);
};
class AbstractFunctionBase {
public:
public :
string name;
string type;
string src;
public:
constructor(string n, string n_type, string n_src);
string getType();
// FIXME: not appropriate for pgsql triggers for example
string getDropSql();
bool equal(AbstractFunctionBase t);
private abstract bool equalImpl(AbstractFunctionBase t);
};
class AbstractFunction : public AbstractFunctionBase {
public:
constructor(string n, string n_type, string n_src);
abstract list getCreateSql(*hash opt);
abstract list getRenameSql(string new_name);
setName(string new_name);
};
class Functions : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractFunction val);
AbstractFunction take(string k);
AbstractFunction memberGate(string k);
string getElementName();
};
class AbstractTrigger : public AbstractFunctionBase {
public:
constructor(string n, string n_src);
abstract list getCreateSql(string table_name, *hash opt);
abstract list getRenameSql(string table_name, string new_name);
abstract list getDropSql(string table_name);
};
class Triggers : public AbstractHashContainer {
public:
constructor(*hash c);
add(string k, AbstractTrigger val);
AbstractTrigger take(string k);
AbstractTrigger memberGate(string k);
string getElementName();
};
class Database {
public:
private :
AbstractDatabase db;
public:
constructor(AbstractDatasource ds, *hash opts);
constructor(string ds, *hash opts);
constructor(hash ds, *hash opts);
any tryExec(string sql);
any tryExecArgs(string sql, *softlist args);
any tryExecRaw(string sql);
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache);
list getDropSchemaSql(hash schema_hash, *hash opt);
Qore::SQL::AbstractDatasource getDatasource();
any methodGate(string meth);
AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
AbstractTable makeTable(string name, hash desc, *hash opts);
AbstractFunction makeFunction(string name, string src, *hash opt);
AbstractFunction makeProcedure(string name, string src, *hash opt);
bool dropFunctionIfExists(string name, *hash opt);
bool dropProcedureIfExists(string name, *hash opt);
bool dropSequenceIfExists(string name, *hash opt);
bool dropTableIfExists(string name, *hash opt);
list getAlignFunctionSql(AbstractFunction f, *hash opt);
list getAlignProcedureSql(AbstractFunction f, *hash opt);
*AbstractTable getTable(string name);
*AbstractSequence getSequence(string name);
*AbstractFunction getFunction(string name);
*AbstractFunction getProcedure(string name);
*AbstractView getView(string name);
int getNextSequenceValue(string name);
string getSqlFromList(list l);
bool supportsSequences();
list listTables();
Qore::ListIterator tableIterator();
list listFunctions();
Qore::ListIterator functionIterator();
list listProcedures();
Qore::ListIterator procedureIterator();
list listSequences();
Qore::ListIterator sequenceIterator();
list listViews();
Qore::ListIterator viewIterator();
};
class AbstractSqlUtilBase {
public:
private :
AbstractDatasource ds;
string dsdesc;
Mutex l();
*hash opts;
public:
private constructor(AbstractDatasource nds, *hash nopts);
private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
private:
static validateOptionIntern(string err, string type, reference opt, string k, string tag);
public:
Qore::SQL::AbstractDatasource getDatasource();
string getDriverName();
string getDatasourceDesc();
};
class AbstractDatabase : public AbstractSqlUtilBase {
public:
public :
const DatabaseOptions = (
"native_case": Type::Boolean,
);
const CacheOptions = (
"table_cache": "Tables",
);
const CallbackOptions = (
"info_callback": "code",
"sql_callback": "code",
"sql_callback_executed": Type::Boolean,
);
const AC_Unchanged = 0;
const AC_Create = 1;
const AC_Drop = 2;
const AC_Rename = 3;
const AC_Modify = 4;
const AC_Truncate = 5;
const AC_Add = 6;
const AC_Recreate = 7;
const AC_Insert = 8;
const AC_Update = 9;
const AC_Delete = 10;
const AC_NotFound = 11;
const ActionMap = (
AC_Unchanged: "unchanged",
AC_Create: "create",
AC_Drop: "drop",
AC_Rename: "rename",
AC_Modify: "modify",
AC_Truncate: "truncate",
AC_Add: "add",
AC_Recreate: "recreate",
AC_Insert: "insert",
AC_Update: "update",
AC_Delete: "delete",
AC_NotFound: "not found",
);
const ActionDescMap = (
"unchanged": AC_Unchanged,
"create": AC_Create,
"drop": AC_Drop,
"rename": AC_Rename,
"modify": AC_Modify,
"truncate": AC_Truncate,
"add": AC_Add,
"recreate": AC_Recreate,
"insert": AC_Insert,
"update": AC_Update,
"delete": AC_Delete,
"not found": AC_NotFound,
);
const ActionLetterMap = (
AC_Unchanged: ".",
AC_Create: "C",
AC_Drop: "D",
AC_Rename: "N",
AC_Modify: "M",
AC_Truncate: "T",
AC_Add: "A",
AC_Recreate: "R",
AC_Insert: "I",
AC_Update: "U",
AC_Delete: "X",
AC_NotFound: ".",
);
const CreationOptions = CallbackOptions + (
"replace": Type::Boolean,
"table_cache": "Tables",
"data_tablespace": Type::String,
"index_tablespace": Type::String,
);
const AlignSchemaOptions = CreationOptions;
const DropSchemaOptions = CallbackOptions;
const SchemaDescriptionOptions = (
"tables": Type::Hash,
"table_map": Type::Hash,
"sequences": Type::Hash,
"sequence_map": Type::Hash,
"functions": Type::Hash,
"function_map": Type::Hash,
"procedures": Type::Hash,
"procedure_map": Type::Hash,
//"views": Type::Hash,
//"view_map": Type::Hash,
);
const SequenceDescriptionOptions = (
"start": Type::Int,
"increment": Type::Int,
"end": Type::Int,
);
public:
private :
bool native_case = False;
public:
private constructor(AbstractDatasource nds, *hash nopts);
list features();
static doOkCallback(*hash opt, int ac, string type, string name, *string table, *string info);
static *string doCallback(*hash opt, *string sql, int ac, string type, string name, *string table, *string new_name, *string info);
static list doCallback(*hash opt, list sql, int ac, string type, string name, *string table, *string new_name, *string info);
/*
static *string doCallback(*hash opt, *string sql, string fmt) {
if (!sql)
return;
if (opt.info_callback)
opt.info_callback(vsprintf(fmt, argv));
if (opt.sql_callback)
opt.sql_callback(sql);
return sql;
}
static list doCallback(*hash opt, list sql, string fmt) {
if (sql) {
if (opt.info_callback)
opt.info_callback(vsprintf(fmt, argv));
if (opt.sql_callback)
map opt.sql_callback($1), sql;
}
return sql;
}
*/
any tryExec(string sql);
any tryExecArgs(string sql, *softlist args);
any tryExecRaw(string sql);
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache);
list getDropSchemaSql(hash schema_hash, *hash opt);
private list dropSqlUnlocked(string type, hash schema_hash, code get, code make, *hash opt, string make_arg_type);
private list alignCodeUnlocked(string type, hash schema_hash, code get, code make, *hash opt, string make_arg_type);
AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
AbstractSequence makeSequenceFromDescription(string name, *hash sh, *hash opts);
AbstractTable makeTable(string name, hash desc, *hash opts);
AbstractFunction makeFunction(string name, string src, *hash opts);
AbstractFunction makeProcedure(string name, string src, *hash opt);
bool dropFunctionIfExists(string name, *hash opt);
bool dropProcedureIfExists(string name, *hash opt);
bool dropSequenceIfExists(string name, *hash opt);
bool dropViewIfExists(string name, *hash opt);
bool dropTableIfExists(string name, *hash opt);
*string getDropFunctionSqlIfExists(string name, *hash opt);
*string getDropProcedureSqlIfExists(string name, *hash opt);
*string getDropSequenceSqlIfExists(string name, *hash opt);
*list getDropTableSqlIfExists(string name, *hash opt);
doDropSql(*softlist l, string type, string name, *hash opt);
bool doDrop(*softlist l, string type, string name, *hash opt);
list getAlignFunctionSql(AbstractFunction f, *hash opt);
list getAlignProcedureSql(AbstractFunction f, *hash opt);
*AbstractTable getTable(string name);
*AbstractSequence getSequence(string name);
*AbstractFunction getFunction(string name);
*AbstractFunction getProcedure(string name);
*AbstractView getView(string name);
int getNextSequenceValue(string name);
string getSqlFromList(list l);
bool supportsSequences();
bool supportsTypes();
bool supportsPackages();
list listTables();
Qore::ListIterator tableIterator();
list listFunctions();
Qore::ListIterator functionIterator();
list listProcedures();
Qore::ListIterator procedureIterator();
list listSequences();
Qore::ListIterator sequenceIterator();
list listViews();
Qore::ListIterator viewIterator();
private validateOptionsIntern(string err, hash ropt, reference opt);
private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
static AbstractDatabase getDatabase(AbstractDatasource nds, *hash opts);
static AbstractDatabase getDatabase(string dsstr, *hash opts);
static AbstractDatabase getDatabase(hash dsh, *hash opts);
static checkDriverOptions(reference h, string drv);
private hash getDatabaseOptions();
private hash getCallbackOptions();
private hash getCreationOptions();
private hash getCacheOptions();
private hash getAlignSchemaOptions();
private hash getDropSchemaOptions();
private hash getSchemaDescriptionOptions();
private hash getSequenceDescriptionOptions();
private any tryExecArgsImpl(string sql, *softlist args);
private any tryExecRawImpl(string sql);
private abstract string getCreateSqlImpl(list l);
private abstract list getAlignSqlImpl(hash schema_hash, *hash opt);
private abstract list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
private abstract *AbstractSequence getSequenceImpl(string name);
private abstract *AbstractFunction getFunctionImpl(string name);
private abstract *AbstractFunction getProcedureImpl(string name);
private abstract *AbstractView getViewImpl(string name);
private abstract AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
private abstract AbstractFunction makeFunctionImpl(string name, string src, *hash opts);
private abstract AbstractFunction makeProcedureImpl(string name, string src, *hash opts);
private abstract list featuresImpl();
private abstract list listTablesImpl();
private abstract list listFunctionsImpl();
private abstract list listProceduresImpl();
private abstract list listSequencesImpl();
private abstract list listViewsImpl();
private abstract int getNextSequenceValueImpl(string name);
private abstract bool supportsSequencesImpl();
private abstract bool supportsPackagesImpl();
private abstract bool supportsTypesImpl();
};
class Table {
public:
private :
AbstractTable t;
public:
constructor(AbstractDatasource ds, string name, *hash opts);
constructor(string ds, string name, *hash opts);
constructor(hash ds, string name, *hash opts);
constructor(AbstractDatasource ds, hash desc, string name, *hash opts);
setDatasource(AbstractDatasource nds);
commit();
rollback();
string getName();
Qore::SQL::AbstractDatasource getDatasource();
AbstractTable getTable();
any methodGate(string meth);
bool inDb();
setupTable(hash desc, *hash opt);
Qore::AbstractIterator getUniqueConstraintIterator();
drop(*hash opt);
dropNoCommit(*hash opt);
any tryExec(string sql);
any tryExecArgs(string sql, *softlist args);
any tryExecRaw(string sql);
truncate();
truncateNoCommit();
string getTruncateSql(*hash opt);
create(*hash opt);
createNoCommit(*hash opt);
rename(string new_name, *reference sql, *Tables table_cache);
bool emptyData();
bool empty();
AbstractColumn addColumn(string cname, hash opt, bool nullable = True, *reference lsql);
list getAddColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
AbstractColumn modifyColumn(string cname, hash opt, bool nullable = True, *reference lsql);
list getModifyColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
AbstractColumn renameColumn(string old_name, string new_name, reference sql);
string getRenameColumnSql(string old_name, string new_name, *hash opt);
AbstractPrimaryKey addPrimaryKey(string cname, softlist cols, *hash opt, *reference sql);
string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt);
AbstractPrimaryKey dropPrimaryKey(*reference lsql);
list getDropPrimaryKeySql(*hash opt);
AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql);
string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt);
AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql);
string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt);
AbstractIndex renameIndex(string old_name, string new_name, reference sql);
string getDropIndexSql(string iname, *hash opt);
string getDropConstraintSql(string cname, *hash opt);
*string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref);
AbstractIndex dropIndex(string iname, *reference sql);
AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt);
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql);
AbstractForeignConstraint removeForeignConstraint(string cname);
AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql);
string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt);
AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql);
AbstractConstraint dropConstraint(string cname, *reference sql);
AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql);
list getAddTriggerSql(string tname, string src, *hash topt, *hash opt);
AbstractTrigger dropTrigger(string tname, *reference sql);
list getDropTriggerSql(string tname, *hash opt);
string getSqlValue(any v);
AbstractColumn dropColumn(string cname, *reference lsql);
list getDropColumnSql(string cname, *hash opt);
insert(hash row, *reference sql);
insertNoCommit(hash row, *reference sql);
insert(hash row, *hash opt);
insertNoCommit(hash row, *hash opt);
int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql);
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql);
int insertFromSelect(list cols, AbstractTable source, *hash sh, *hash opt);
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *hash opt);
int insertFromIterator(Qore::AbstractIterator i, *hash opt);
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt);
int upsert(hash row, int upsert_strategy = AbstractTable::UpsertAuto);
int upsertNoCommit(hash row, int upsert_strategy = AbstractTable::UpsertAuto);
code getUpsertClosure(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto);
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto);
*hash upsertFromIterator(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromIteratorNoCommit(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelect(AbstractTable src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelectNoCommit(AbstractTable src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelect(Table src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelectNoCommit(Table src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
softint rowCount();
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql);
Qore::SQL::SQLStatement getRowIterator(*hash sh, *hash opt);
*hash selectRow(*hash sh, *reference sql);
*list selectRows(*hash sh, *reference sql);
*hash select(*hash sh, *reference sql);
*hash selectRow(*hash sh, *hash opt);
*list selectRows(*hash sh, *hash opt);
*hash select(*hash sh, *hash opt);
string getSelectSql(*hash sh, *reference args);
int del(*hash cond, *reference sql);
int delNoCommit(*hash cond, *reference sql);
int update(hash set, *hash cond, *reference sql);
int updateNoCommit(hash set, *hash cond, *reference sql);
int del(*hash cond, *hash opt);
int delNoCommit(*hash cond, *hash opt);
int update(hash set, *hash cond, *hash opt);
int updateNoCommit(hash set, *hash cond, *hash opt);
string getSqlFromList(list l);
string getRenameSql(string new_name, *hash opt);
string getCreateSqlString(*hash opt);
list getCreateSql(*hash opt);
string getCreateTableSql(*hash opt);
*list getCreateIndexesSql(*hash opt);
*string getCreatePrimaryKeySql(*hash opt);
*list getCreateForeignConstraintsSql(*hash opt);
*list getCreateConstraintsSql(*hash opt);
*list getCreateMiscSql(*hash opt);
*list getCreateTriggersSql(*hash opt);
list getAlignSql(AbstractTable table, *hash opt);
list getAlignSql(Table table, *hash opt);
string getAlignSqlString(AbstractTable table, *hash opt);
string getAlignSqlString(Table table, *hash opt);
*hash find(any id);
*list find(list ids);
*hash find(hash row);
*hash findSingle(*hash cond);
*list findAll(*hash cond);
cache(*hash opts);
clear();
Columns describe();
AbstractPrimaryKey getPrimaryKey();
*AbstractUniqueConstraint findUniqueConstraint(string name);
Indexes getIndexes();
Triggers getTriggers();
ForeignConstraints getForeignConstraints(*hash opt);
Constraints getConstraints();
string getDriverName();
};
class AbstractTable : public AbstractSqlUtilBase {
public:
public :
const TableOptions = (
"native_case": Type::Boolean,
"table_cache": "Tables",
);
const IndexOptions = (
"index_tablespace": Type::String,
"replace": Type::Boolean,
);
const ConstraintOptions = IndexOptions;
const CacheOptions = (
"table_cache": "Tables",
);
const ForeignConstraintOptions = ConstraintOptions + (
"table_cache": "Tables",
);
const TriggerOptions = AbstractDatabase::CreationOptions;
const SelectOptions = (
"comment": Type::String,
"hint": Type::String,
"columns": Type::NothingType,
"where": "hash/list",
"orderby": "softstringhashlist",
"desc": Type::Boolean,
"limit": Type::Int,
"offset": Type::Int,
"join": Type::Hash,
"groupby": "softstringhashlist",
"having": Type::Hash,
"superquery": Type::Hash,
);
const TableOmissionOptions = (
"indexes": True,
"foreign_constraints": True,
"triggers": True,
);
const TableCreationOptions = IndexOptions + AbstractDatabase::CreationOptions + (
"omit": "softstringlist",
);
const AlignTableOptions = TableCreationOptions + (
"column_map": Type::Hash,
"index_map": Type::Hash,
"constraint_map": Type::Hash,
"trigger_map": Type::Hash,
"db_table_cache": "Tables",
);
const TableDescriptionHashOptions = (
"columns": Type::Hash,
"primary_key": Type::Hash,
"indexes": Type::Hash,
"triggers": Type::Hash,
"foreign_constraints": Type::Hash,
"unique_constraints": Type::Hash,
//"check_constraints": Type::Hash,
"table_cache": "Tables",
);
const ColumnDescOptions = (
"qore_type": Type::String,
"native_type": Type::String,
"size": Type::Int,
"scale": Type::Int,
"default_value": Type::NothingType,
"comment": Type::String,
);
const AdditionalColumnDescOptions = (
"notnull": Type::Boolean,
);
const ColumnOptions = hash();
const SqlDataCallbackOptions = (
"sqlarg_callback": "code",
);
const UpsertOptions = (
"info_callback": "code",
"commit_block": Type::Int,
"delete_others": Type::Boolean,
);
const InsertOptions = SqlDataCallbackOptions + (
"info_callback": "code",
"commit_block": Type::Int,
);
const UpsertInsertFirst = 1;
const UpsertUpdateFirst = 2;
const UpsertSelectFirst = 3;
const UpsertAuto = 4;
const UpsertInsertOnly = 5;
const UR_Inserted = 1;
const UR_Verified = 2;
const UR_Updated = 3;
const UR_Unchanged = 4;
const UR_Deleted = 5;
const UpsertResultMap = (
UR_Inserted: "inserted",
UR_Verified: "verified",
UR_Updated: "updated",
UR_Unchanged: "unchanged",
UR_Deleted: "deleted",
);
const UpsertResultDescriptionMap = (
"inserted": UR_Inserted,
"verified": UR_Verified,
"updated": UR_Updated,
"unchanged": UR_Unchanged,
"deleted": UR_Deleted,
);
const UpsertResultLetterMap = (
UR_Inserted: "I",
UR_Verified: "V",
UR_Updated: "U",
UR_Unchanged: ".",
UR_Deleted: "X",
);
public:
private :
string name;
Columns columns;
AbstractPrimaryKey primaryKey;
Indexes indexes;
ForeignConstraints foreignConstraints;
Constraints constraints;
Triggers triggers;
bool native_case = False;
bool inDb = False;
bool manual = False;
public:
private constructor(AbstractDatasource nds, string nname, *hash nopts);
copy(AbstractTable old);
setDatasource(AbstractDatasource nds);
private doTableOptions(*hash nopts);
commit();
rollback();
bool inDb();
Qore::AbstractIterator getUniqueConstraintIterator();
drop(*hash opt);
any tryExec(string sql);
any tryExecArgs(string sql, *softlist args);
any tryExecRaw(string sql);
dropNoCommit(*hash opt);
softlist getDropSql(*hash opt);
truncate();
truncateNoCommit();
string getTruncateSql(*hash opt);
create(*hash opt);
createNoCommit(*hash opt);
rename(string new_name, *reference sql, *Tables table_cache);
private doRenameIntern(string new_name, *Tables table_cache);
bool emptyData();
bool empty();
private bool emptyUnlocked();
setupTable(hash desc, *hash opt);
AbstractColumn addColumn(string cname, hash opt, bool nullable = True, *reference lsql);
list getAddColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
private AbstractColumn addColumnUnlocked(string cname, hash opt, bool nullable = True, *reference lsql, bool do_exec = True, bool modify_table = True);
private addColumnToTableUnlocked(AbstractColumn c);
AbstractColumn modifyColumn(string cname, hash opt, bool nullable = True, *reference lsql);
list getModifyColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
AbstractColumn renameColumn(string old_name, string new_name, reference sql);
string getRenameColumnSql(string old_name, string new_name, *hash opt);
private AbstractColumn renameColumnIntern(AbstractColumn c, string new_name);
private validateOptionsIntern(string err, hash ropt, reference opt);
private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
private execSql(softlist lsql);
AbstractPrimaryKey addPrimaryKey(string pkname, softlist cols, *hash opt, *reference sql);
string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt);
private setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
private AbstractPrimaryKey addPrimaryKeyUnlocked(string pkname, softlist cols, *hash opt, *reference sql);
private AbstractPrimaryKey addPrimaryKeyUnlockedIntern(string pkname, softlist cols, *hash opt, *reference sql);
list getDropAllConstraintsAndIndexesOnColumnSql(string cname, *hash opt);
private list getDropAllConstraintsAndIndexesOnColumnSqlUnlocked(string cname, *hash opt);
list getDropPrimaryKeySql(*hash opt);
AbstractPrimaryKey dropPrimaryKey(*reference lsql);
AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql);
string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt);
private AbstractUniqueConstraint addUniqueConstraintUnlocked(string cname, softlist cols, *hash opt, *reference sql);
private AbstractUniqueConstraint addUniqueConstraintUnlockedIntern(string cname, softlist cols, *hash opt, *reference sql);
AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql);
string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt);
private AbstractIndex addIndexUnlocked(string iname, bool unique, softlist cols, *hash opt, *reference sql);
private AbstractIndex addIndexUnlockedIntern(string iname, bool unique, softlist cols, *hash opt, *reference sql);
AbstractIndex renameIndex(string old_name, string new_name, reference sql);
AbstractIndex dropIndex(string iname, *reference sql);
string getDropIndexSql(string iname, *hash opt);
AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt);
private Columns getReferencedTableColumnsUnlocked(string table, *Tables cache, string err = "FOREIGN-CONSTRAINT-ERROR");
private AbstractForeignConstraint addForeignConstraintUnlocked(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
private AbstractForeignConstraint addForeignConstraintUnlockedIntern(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql);
AbstractForeignConstraint removeForeignConstraint(string cname);
AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql);
string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt);
private AbstractCheckConstraint addCheckConstraintUnlocked(string cname, string src, *hash opt, *reference sql);
private AbstractCheckConstraint addCheckConstraintUnlockedIntern(string cname, string src, *hash opt, *reference sql);
AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql);
string getDropConstraintSql(string cname, *hash opt);
*string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref);
private AbstractConstraint findDropConstraintUnlocked(string cname, reference rmv);
AbstractConstraint dropConstraint(string cname, *reference sql);
AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql);
list getAddTriggerSql(string tname, string src, *hash topt, *hash opt);
private AbstractTrigger addTriggerUnlocked(string tname, string src, *hash opt, *reference lsql);
private AbstractTrigger addTriggerUnlockedIntern(string tname, string src, *hash opt, *reference lsql);
AbstractTrigger dropTrigger(string tname, *reference sql);
list getDropTriggerSql(string tname, *hash opt);
private getAllConstraintsUnlocked(*hash opt);
private checkUniqueConstraintName(string err, string cname);
private checkUniqueConstraintNameValidateOptions(string err, string cname, hash ropt, reference opt);
private validateColumnOptions(string cname, reference opt, bool nullable);
AbstractColumn dropColumn(string cname, *reference lsql);
list getDropColumnSql(string cname, *hash opt);
insert(hash row, *reference sql);
insertNoCommit(hash row, *reference sql);
private insertNoCommitIntern(hash row, *reference sql, *hash opt);
insert(hash row, *hash opt);
insertNoCommit(hash row, *hash opt);
int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql);
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql);
private int insertFromSelectNoCommitIntern(list cols, AbstractTable source, *hash sh, *reference sql, *hash opt);
int insertFromSelect(list cols, AbstractTable source, *hash sh, *hash opt);
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *hash opt);
int insertFromIterator(Qore::AbstractIterator i, *hash opt);
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt);
private int insertFromIteratorNoCommitIntern(Qore::AbstractIterator i, *hash opt);
int upsert(hash row, int upsert_strategy = UpsertAuto);
int upsertNoCommit(hash row, int upsert_strategy = UpsertAuto);
code getUpsertClosure(hash example_row, int upsert_strategy = UpsertAuto);
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy = UpsertAuto);
*hash upsertFromIterator(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromIteratorNoCommit(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
private *hash upsertFromIteratorNoCommitIntern(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
private *hash doDeleteOthersIntern(hash pkh, *hash opt);
*hash upsertFromSelect(AbstractTable t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelectNoCommit(AbstractTable t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelect(Table t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
*hash upsertFromSelectNoCommit(Table t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
softint rowCount();
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql);
private Qore::SQL::SQLStatement getRowIteratorIntern(*hash sh, *reference sql, *hash opt);
Qore::SQL::SQLStatement getRowIterator(*hash sh, *hash opt);
*hash selectRow(*hash sh, *reference sql);
*list selectRows(*hash sh, *reference sql);
*hash select(*hash sh, *reference sql);
*hash selectRow(*hash sh, *hash opt);
*list selectRows(*hash sh, *hash opt);
*hash select(*hash sh, *hash opt);
string getSelectSql(*hash sh, *reference args);
*AbstractUniqueConstraint matchAnyUnique(list cols);
string getSelectSqlIntern(*hash qh, reference args);
string getSelectSqlUnlocked(*hash qh, reference args);
string getSelectSqlUnlockedIntern(*hash qh, string from, reference args, *hash ch);
private string getSelectSqlName(*hash qh);
private string getColumnExpressionIntern(any cvc, *hash jch, bool join, *hash ch);
private string doColumnOperatorIntern(hash cvc, *hash jch, bool join, *hash ch);
private string doColumnOperatorIntern(any cop, any arg, *string cve, hash cm, *hash jch, bool join, *hash ch);
private string getColumnNameIntern(string cv, *hash jch, bool join, *hash ch);
private getSelectWhereSqlUnlocked(reference sql, reference args, *hash qh, *hash jch, bool join = False, *hash ch);
private *string getWhereClause(*hash cond, reference args, *string cprefix, *hash jch, bool join = False);
private *string getWhereClause(list cond, reference args, *string cprefix, *hash jch, bool join = False);
private *string getWhereClauseUnlocked(list cond, reference args, *string cprefix, *hash jch, bool join = False, *hash pch);
private *string getWhereClauseUnlocked(*hash cond, reference args, *string cprefix, *hash jch, bool join = False, *hash pch);
private *list getWhereClauseIntern(*hash cond, reference args, *string cprefix, *hash jch, bool join = False, *hash ch);
private string doWhereExpressionIntern(string cn, any we, reference args, *hash jch, bool join = False, *hash ch);
private list getOrderByListUnlocked(*hash qh, *hash jch, *hash ch);
private doSelectOrderBySqlUnlocked(reference sql, reference args, *hash qh, *hash jch, *hash ch);
int del(*hash cond, *reference sql);
int delNoCommit(*hash cond, *reference sql);
private int delNoCommitIntern(*hash cond, *reference sql, *hash opt);
int update(hash set, *hash cond, *reference sql);
int updateNoCommit(hash set, *hash cond, *reference sql);
private int updateNoCommitIntern(hash set, *hash cond, *reference sql, *hash opt);
int del(*hash cond, *hash opt);
int delNoCommit(*hash cond, *hash opt);
int update(hash set, *hash cond, *hash opt);
int updateNoCommit(hash set, *hash cond, *hash opt);
private string getUpdateExpression(string col, hash uh);
private bool emptyDataUnlocked();
private code getUpsertClosureUnlocked(hash row, int upsert_strategy = UpsertAuto);
private code getUpsertInsertFirst(Columns cols, hash example_row);
private code getUpsertUpdateFirst(Columns cols, hash example_row);
private code getUpsertSelectFirst(Columns cols, hash example_row);
private code getUpsertInsertOnly(Columns cols, hash example_row);
private Columns getUpsertColumns(reference csrc);
private string getUpsertSelectSql(hash row, Columns cols, reference updc);
private string getUpsertInsertSql(hash row);
private string getUpsertUpdateSql(hash row, Columns cols, reference updc);
private softbool tryUpdate(string sql, hash row, Columns cols, list updc);
private checkValue(string cname, string argname, reference val, string type);
string getSqlFromList(list l);
string getSqlValue(any v);
string getName();
cache(*hash opts);
clear();
Columns describe();
AbstractPrimaryKey getPrimaryKey();
*AbstractUniqueConstraint findUniqueConstraint(string name);
*AbstractUniqueConstraint findUniqueConstraintUnlocked(string name);
Indexes getIndexes();
ForeignConstraints getForeignConstraints(*hash opt);
Constraints getConstraints();
Triggers getTriggers();
string getRenameSql(string new_name, *hash opt);
string getCreateSqlString(*hash opt);
list getCreateSql(*hash opt);
string getCreateTableSql(*hash opt);
bool checkExistence();
private *hash getCheckOmissionOptions(*softlist ol, string err);
list getAlignSql(AbstractTable t, *hash opt);
private list getAlignSqlUnlocked(AbstractTable t, *hash opt);
private renameIndexUnlocked(AbstractIndex ix, string new_name);
string getAlignSqlString(AbstractTable t, *hash opt);
*list getCreateIndexesSql(*hash opt, bool cache = True);
*string getCreatePrimaryKeySql(*hash opt, bool cache = True);
*list getCreateForeignConstraintsSql(*hash opt, bool cache = True);
*list getCreateConstraintsSql(*hash opt, bool cache = True);
*list getCreateMiscSql(*hash opt, bool cache = True);
*list getCreateTriggersSql(*hash opt, bool cache = True);
*hash find(any id);
*list find(list ids);
private string getPrimaryKeyColumn();
*hash find(hash row);
*hash findSingle(*hash cond);
*list findAll(*hash cond);
string getSqlName();
private hash getTableOptions();
private hash getForeignConstraintOptions();
private hash getConstraintOptions();
private hash getCacheOptions();
private hash getTableCreationOptions();
private hash getAlignTableOptions();
private hash getTableDescriptionHashOptions();
private hash getColumnOptions();
private hash getColumnDescOptions();
private hash getTableColumnDescOptions();
private hash getIndexOptions();
private hash getTriggerOptions();
private hash getSelectOptions();
private hash getUpsertOptions();
private hash getInsertOptions();
private hash getSqlDataCallbackOptions();
private hash getWhereOperatorMap();
private hash getColumnOperatorMap();
private hash getUpdateOperatorMap();
private string getCreateTableSqlUnlocked(*hash opt);
private *list getCreateIndexesSqlUnlocked(*hash opt, bool cache = True);
private *string getCreatePrimaryKeySqlUnlocked(*hash opt, bool cache = True);
private *list getCreateConstraintsSqlUnlocked(*hash opt, bool cache = True);
private *list getCreateForeignConstraintsSqlUnlocked(*hash opt, bool cache = True);
private *list getCreateMiscSqlUnlocked(*hash opt, bool cache = True);
private *list getCreateTriggersSqlUnlocked(*hash opt, bool cache = True);
private list getCreateSqlUnlocked(*hash opt, bool cache = True);
private cacheUnlocked(*hash opt);
private any execData(*hash opt, string sql, *list args);
private execData(SQLStatement stmt, *hash opt, *list args);
static AbstractTable getTable(AbstractDatasource nds, string nname, *hash opts);
static AbstractTable getTable(string dsstr, string nname, *hash opts);
static AbstractTable getTable(hash dsh, string nname, *hash opts);
private getColumnsUnlocked();
private getPrimaryKeyUnlocked();
// also loads primary key and constraints (for unique constraints)
private getIndexesUnlocked();
private getForeignConstraintsUnlocked(*hash opt);
private addSourceConstraint(string table_name, AbstractForeignConstraint fk);
private getConstraintsUnlocked();
private getTriggersUnlocked();
private softlist getDropSqlImpl();
private string getTruncateSqlImpl();
private any tryExecArgsImpl(string sql, *softlist args);
private any tryExecRawImpl(string sql);
private clearImpl();
private preSetupTableImpl(reference desc, *hash opt);
private abstract bool emptyImpl();
private abstract *string getSqlValueImpl(any v);
private abstract bool checkExistenceImpl();
private abstract bool supportsTablespacesImpl();
private abstract bool constraintsLinkedToIndexesImpl();
private abstract bool uniqueIndexCreatesConstraintImpl();
private abstract setupTableImpl(hash desc, *hash opt);
private abstract Columns describeImpl();
private abstract AbstractPrimaryKey getPrimaryKeyImpl();
private abstract Indexes getIndexesImpl();
private abstract ForeignConstraints getForeignConstraintsImpl(*hash opt);
private abstract Constraints getConstraintsImpl();
private abstract Triggers getTriggersImpl();
private abstract string getCreateTableSqlImpl(*hash opt);
private abstract *list getCreateMiscSqlImpl(*hash opt, bool cache);
private abstract string getCreateSqlImpl(list l);
private abstract string getRenameSqlImpl(string new_name);
private abstract *list getAlignSqlImpl(AbstractTable t, *hash opt);
private abstract AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
private abstract AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
private abstract AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
private abstract AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
private abstract AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
private abstract AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
private abstract AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
private abstract bool tryInsertImpl(string sql, hash row);
private abstract hash getQoreTypeMapImpl();
private abstract hash getTypeMapImpl();
private abstract doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch);
private abstract doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh);
private abstract copyImpl(AbstractTable old);
};
/*
public class Sqlite3Table inherits AbstractTable {
public {
const Sqlite3TypeMap = (
"INTEGER": ("qore": "integer",),
"NUMERIC": ("qore": "number",),
"TEXT": ("qore": "string",),
"BLOB": ("qore": "binary",),
"NONE": ("qore": "any",),
"REAL": ("qore": "float",),
);
const QoreTypeMap = (
"integer": "INTEGER",
"float": "NUMBER",
"number": "NUMBER",
"string": "VARCHAR2",
#"date": "TIMESTAMP",
"binary": "BLOB",
);
}
constructor(AbstractDatasource nds, string nname, *hash opts) : AbstractTable(nds, nname, opts) {
}
private hash describeImpl() {
hash rv;
# NOTE: sqlite3's pragmas cannot use %v binding
# table info - PK is part of the table description
hash tableInfo = ds.select("pragma table_info(%s)", name);
context(tableInfo) {
rv.columns{%name} = (
"native_type" : %type,
"qore_type" : Sqlite3TypeMap{%type}.qore,
"size" : NOTHING,
"nullable" : %notnull == 1 ? NOTHING : "YES",
);
if (%pk)
rv.primary_key{%name} = True;
}
# get index description
hash indexes = ds.select("pragma index_list(%s)", name);
context(indexes) {
rv.indexes{%name}.unique = %unique == 0 ? False : True;
hash indexColumns = ds.select("pragma index_info(%s)", %name);
string columnName = %name;
context (indexColumns) {
rv.indexes{columnName}.columns{%name} = True;
}
}
# TODO/FIXME: FKs
return rv;
}
}
*/
}
SqlUtil::AbstractIndex::getRenameSql
abstract string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
SqlUtil::AbstractDatabase::ActionMap
const ActionMap
maps from action codes to action descriptions
Definition: SqlUtil.qm.dox.h:4991
SqlUtil::Table::getAlignSql
list getAlignSql(AbstractTable table, *hash opt)
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure a...
SqlUtil::AbstractConstraint::name
string name
the name of the constraint
Definition: SqlUtil.qm.dox.h:3916
SqlUtil::Table::getRenameColumnSql
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
SqlUtil::AbstractSequence::constructor
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_max)
creates the object from the arguments
SqlUtil::AbstractTable::insertFromSelect
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 sam...
SqlUtil::cop_avg
hash cop_avg(any column)
returns a hash for the &quot;avg&quot; operator; returns average column values
SqlUtil::Columns::getElementName
string getElementName()
returns &quot;column&quot; since this object stores column objects
SqlUtil::AbstractTable::getDropSql
softlist getDropSql(*hash opt)
returns the sql required to drop the table; reimplement in subclasses if necessary ...
SqlUtil::AbstractConstraint::hasColumn
bool hasColumn(string cname)
returns True if the constraint references the named column
SqlUtil::Tables::constructor
constructor()
creates an empty object
SqlUtil::AbstractUniqueConstraint::index
*string index
the index supporting the constraint
Definition: SqlUtil.qm.dox.h:4004
SqlUtil::AbstractTable::addIndex
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 ...
SqlUtil::AbstractTable::createNoCommit
createNoCommit(*hash opt)
creates the table with all associated properties (indexes, constraints, etc) without any transaction ...
SqlUtil::AbstractTable::SelectOptions
const SelectOptions
default select options
Definition: SqlUtil.qm.dox.h:8217
SqlUtil::AbstractFunctionBase::getDropSql
string getDropSql()
returns a string that can be used to drop the function from the database
SqlUtil::AbstractTable::getConstraints
Constraints getConstraints()
returns a Constraints object describing the non-foreign constraints on the table
SqlUtil::AbstractTable::getCacheOptions
private hash getCacheOptions()
returns the cache options for this driver
SqlUtil::Table::find
*hash find(any id)
finds a row in the table with the given primary key value; if no row matches the primary key value pa...
SqlUtil::AbstractSequence::name
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:4185
SqlUtil::uop_lower
hash uop_lower(*hash nest)
returns a hash for the &quot;lower&quot; operator with the given argument; returns a column value in lower case...
SqlUtil::AbstractForeignConstraint::setIndexBase
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
SqlUtil::AbstractHashContainer::pairIterator
Qore::AbstractIterator pairIterator()
Returns a HashPairIterator object for the contained hash.
SqlUtil::Database::getProcedure
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
Hash
const Hash
SqlUtil::AbstractTable::UpsertAuto
const UpsertAuto
Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst...
Definition: SqlUtil.qm.dox.h:8392
SqlUtil::Table::getTruncateSql
string getTruncateSql(*hash opt)
gets the SQL that can be used to truncate the table
SqlUtil::AbstractDatabase::getAlignProcedureSql
list getAlignProcedureSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a stored procedure in the database to the st...
SqlUtil::Table::getAddIndexSql
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
String
const String
SqlUtil::AbstractSqlUtilBase::getDatasource
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
SqlUtil::op_cge
hash op_cge(string arg)
returns a hash for the &quot;&gt;=&quot; operator with the given argument for use in where clauses when comparing ...
SqlUtil::Table::updateNoCommit
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 tr...
SqlUtil::AbstractTable::getTriggerOptions
private hash getTriggerOptions()
returns the trigger options for this driver
SqlUtil::AbstractListContainer
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:3308
SqlUtil::Table::getCreateTriggersSql
*list getCreateTriggersSql(*hash opt)
returns a list of SQL strings that could be used to create triggers on the table or NOTHING if there ...
SqlUtil::Table::inDb
bool inDb()
returns True if the table has been read from or created in the database, False if not ...
SqlUtil::AbstractTable::TableOmissionOptions
const TableOmissionOptions
alignment omission options
Definition: SqlUtil.qm.dox.h:8233
SqlUtil::AbstractSequence::getDropSql
string getDropSql()
returns a string that can be used to drop the sequence from the database
SqlUtil::AbstractDatabase::getDropSchemaSql
list getDropSchemaSql(hash schema_hash, *hash opt)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
SqlUtil::AbstractHashContainer::copy
copy(AbstractHashContainer old)
creates a &quot;deep copy&quot; of the object
SqlUtil::cop_append
hash cop_append(any column, string arg)
returns a hash for the &quot;append&quot; operator with the given argument
SqlUtil::uop_append
hash uop_append(string arg, *hash nest)
returns a hash for the &quot;append&quot; or concatenate operator with the given argument
sprintf
string sprintf(string fmt,...)
SqlUtil::AbstractHashContainer::constructor
constructor(*hash nh)
creates the object with the hash argument passed
SqlUtil::AbstractListContainer::iterator
Qore::ListIterator iterator()
Returns a ListIterator object for the contained list.
SqlUtil::AbstractDatabase::getDatabaseOptions
private hash getDatabaseOptions()
override in subclasses to return driver-specific options
SqlUtil::AbstractDatabase::AC_Unchanged
const AC_Unchanged
used when an existing object matches the template and no changes are made
Definition: SqlUtil.qm.dox.h:4954
SqlUtil::Functions::getElementName
string getElementName()
must return the name of the contained element
SqlUtil::ForeignConstraintTarget::equal
bool equal(ForeignConstraintTarget targ)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractTable::modifyColumn
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...
SqlUtil::AbstractDatabase::dropProcedureIfExists
bool dropProcedureIfExists(string name, *hash opt)
drops the given procedure if it exists; returns True if the procedure was dropped, False if not
SqlUtil::OP_IN
const OP_IN
the SQL &quot;in&quot; operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2647
SqlUtil::AbstractTable::checkExistence
bool checkExistence()
returns True if the table exists in the database, False if not
SqlUtil::AbstractHashContainer::getHash
*hash getHash()
returns the hash contained by this object
SqlUtil::AbstractTable
the base abstract class for the table implementation
Definition: SqlUtil.qm.dox.h:8157
SqlUtil::DefaultCopMap
const DefaultCopMap
a hash of default column operator descriptions
Definition: SqlUtil.qm.dox.h:1759
SqlUtil::AbstractConstraint::equal
bool equal(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractTable::tryExec
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::Table::methodGate
any methodGate(string meth)
executes a method on the contained AbstractTable object
SqlUtil::AbstractIndex::equalExceptName
bool equalExceptName(AbstractIndex ix)
returns True if the argument is equal to the current index with the exception of the name...
SqlUtil::VARCHAR
const VARCHAR
specifies a VARCHAR column (equivalent to Qore::Type::String)
Definition: SqlUtil.qm.dox.h:1622
SqlUtil::Functions::memberGate
AbstractFunction memberGate(string k)
returns the AbstractFunction object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::Table::findUniqueConstraint
*AbstractUniqueConstraint findUniqueConstraint(string name)
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary...
SqlUtil::uop_upper
hash uop_upper(*hash nest)
returns a hash for the &quot;upper&quot; operator with the given argument; returns a column value in upper case...
SqlUtil::AbstractDatabase::getAlignFunctionSql
list getAlignFunctionSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a function in the database to the function d...
SqlUtil::AbstractTable::ForeignConstraintOptions
const ForeignConstraintOptions
default foreign constraint options
Definition: SqlUtil.qm.dox.h:8195
SqlUtil::Table::getAddPrimaryKeySql
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
SqlUtil::AbstractTable::delNoCommit
int delNoCommit(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; no transactio...
SqlUtil::AbstractTable::ColumnOptions
const ColumnOptions
Column options; this is currently empty and can be extended in database-specific modules.
Definition: SqlUtil.qm.dox.h:8316
SqlUtil::Tables
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:3397
SqlUtil::Table::getCreateForeignConstraintsSql
*list getCreateForeignConstraintsSql(*hash opt)
returns a list of SQL strings that could be used to create foreign constraints on the table or NOTHIN...
SqlUtil::AbstractTable::getUniqueConstraintIterator
Qore::AbstractIterator getUniqueConstraintIterator()
returns an iterator for all unique constraints on the table (including the primary key if any) ...
SqlUtil::AbstractConstraint::constructor
constructor(string n)
creates the object and sets its name
SqlUtil::AbstractView::updatable
bool updatable
Flag showing if is the view updatable with DML commands.
Definition: SqlUtil.qm.dox.h:4228
SqlUtil::AbstractDatabase::getCreationOptions
private hash getCreationOptions()
override in subclasses to return driver-specific options
SqlUtil::Table::drop
drop(*hash opt)
drops the table from the database; releases the transaction lock after dropping the table ...
SqlUtil::Table::getDropConstraintIfExistsSql
*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 NOT...
SqlUtil::AbstractCheckConstraint::equalImpl
private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractTable::getAddPrimaryKeySql
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
SqlUtil::op_between
hash op_between(any l, any r)
returns a hash for the &quot;between&quot; operator with the given arguments, neither of which can be NULL or N...
SqlUtil::AbstractView::getCreateSql
abstract string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
SqlUtil::AbstractTable::UpsertResultLetterMap
const UpsertResultLetterMap
maps upsert result codes to single letter symbols
Definition: SqlUtil.qm.dox.h:8445
SqlUtil::Database::getAlignSql
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
now_us
date now_us()
SqlUtil::Indexes::take
AbstractIndex take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::Table::update
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 t...
SqlUtil::AbstractSequence::getCreateSql
abstract string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
SqlUtil::AbstractTrigger::getRenameSql
abstract list getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
SqlUtil::AbstractDatabase::DropSchemaOptions
const DropSchemaOptions
default generic drop schema options
Definition: SqlUtil.qm.dox.h:5060
SqlUtil::Table::getDropIndexSql
string getDropIndexSql(string iname, *hash opt)
gets the SQL that can be used to drop an index from the table
SqlUtil::uop_prepend
hash uop_prepend(string arg, *hash nest)
returns a hash for the &quot;prepend&quot; operator with the given argument
SqlUtil::Table::getCreateTableSql
string getCreateTableSql(*hash opt)
returns an SQL string that could be used to create the basic table structure without indexes and cons...
SqlUtil::AbstractDatabase::SchemaDescriptionOptions
const SchemaDescriptionOptions
default generic schema description keys
Definition: SqlUtil.qm.dox.h:5075
SqlUtil::AbstractTable::UR_Inserted
const UR_Inserted
row was inserted
Definition: SqlUtil.qm.dox.h:8407
SqlUtil::ForeignConstraintTarget::constructor
constructor(string t, Columns c)
creates the object and sets the target table name and the target columns
SqlUtil::AbstractView::constructor
constructor(string n_name, string n_src)
creates the object from the arguments
SqlUtil::Table::getDriverName
string getDriverName()
returns the database driver name
SqlUtil::op_in
hash op_in()
returns a hash for the &quot;in&quot; operator with all arguments passed to the function; for use in where clau...
SqlUtil::AbstractTable::cache
cache(*hash opts)
reads in all attributes of the table from the database
printf
string printf(string fmt,...)
SqlUtil::OP_BETWEEN
const OP_BETWEEN
the SQL &quot;between&quot; operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2642
SqlUtil::AbstractDatabase::getView
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view cannot be found ...
SqlUtil::AbstractTable::upsert
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 k...
SqlUtil::AbstractHashContainer::take
abstract any take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::AbstractDatabase::DatabaseOptions
const DatabaseOptions
database options
Definition: SqlUtil.qm.dox.h:4921
SqlUtil::AbstractConstraint::getDisableSql
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database; if disabli...
SqlUtil::AbstractTable::getIndexOptions
private hash getIndexOptions()
returns the index options for this driver
SqlUtil::AbstractIndex
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:3793
SqlUtil::Constraints::findEqualUniqueConstraint
*AbstractUniqueConstraint findEqualUniqueConstraint(AbstractUniqueConstraint uk)
finds a unique constraint with the same columns as the unique constraint passed
SqlUtil::AbstractUniqueConstraint::sourceConstraints
hash sourceConstraints
a hash of ForeignConstraintSources, keyed by table name, the value is a hash of foreign constraints k...
Definition: SqlUtil.qm.dox.h:4001
SqlUtil::AbstractIndex::getSupportingConstraint
*AbstractUniqueConstraint getSupportingConstraint()
returns the supporting constraint, if any
SqlUtil::AbstractDatabase::procedureIterator
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
SqlUtil::AbstractTable::upsertFromSelectNoCommit
*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 curre...
SqlUtil::AbstractTable::getTriggers
Triggers getTriggers()
returns an object of class Triggers describing the triggers on the table
SqlUtil::Columns::add
add(string k, AbstractColumn val)
adds the given value to the hash with the given key name
SqlUtil::COP_OVER
const COP_OVER
the SQL &quot;over&quot; clause
Definition: SqlUtil.qm.dox.h:1716
SqlUtil::ForeignConstraints
foreign constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:4078
SqlUtil::AbstractTable::UpsertResultDescriptionMap
const UpsertResultDescriptionMap
hash mapping upsert descriptions to codes
Definition: SqlUtil.qm.dox.h:8436
SqlUtil::AbstractForeignConstraint::columns
Columns columns
an object of class Columns giving the source table that make up the constraint
Definition: SqlUtil.qm.dox.h:4152
SqlUtil::AbstractTable::UR_Deleted
const UR_Deleted
row was deleted (only possible with batch upsert methods such as Table::upsertFromIterator() where up...
Definition: SqlUtil.qm.dox.h:8419
SqlUtil::AbstractDatabase::listTables
list listTables()
returns a list of string table names in the database
SqlUtil::Database::dropProcedureIfExists
bool dropProcedureIfExists(string name, *hash opt)
drops the given procedure if it exists; returns True if the procedure was dropped, False if not
SqlUtil::op_ne
hash op_ne(any arg)
returns a hash for the &quot;!=&quot; or &quot;&lt;&gt;&quot; operator with the given argument for use in where clauses when co...
SqlUtil::Database::dropFunctionIfExists
bool dropFunctionIfExists(string name, *hash opt)
drops the given function if it exists; returns True if the function was dropped, False if not ...
SqlUtil::AbstractUniqueConstraint::constructor
constructor(string n, *hash c, *string n_index)
creates the object from the name an a hash of column information
SqlUtil::AbstractTable::uniqueIndexCreatesConstraintImpl
abstract private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
SqlUtil::make_jop
hash make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt)
returns a hash keyed with the table name assigned to a hash with jop, table, jcols, cond, alias, and ta keys
SqlUtil::AbstractForeignConstraint::clearIndex
clearIndex()
clears any index base for the constraint
SqlUtil::Table::removeForeignConstraint
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
SqlUtil::AbstractIndex::hasColumn
bool hasColumn(string cname)
returns True if the constraint references the named column
SqlUtil::OP_NE
const OP_NE
the SQL not equals operator (!= or &lt;&gt;) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2602
SqlUtil::AbstractTable::dropIndex
AbstractIndex dropIndex(string iname, *reference sql)
drops the given index from the table; if the table is known to be in the database already...
Qore::ListIterator
SqlUtil::AbstractTable::dropColumn
AbstractColumn dropColumn(string cname, *reference lsql)
drops a column from the table
SqlUtil::Database::listSequences
list listSequences()
returns a list of string sequence names in the database
SqlUtil::AbstractIndex::setSupportingConstraint
setSupportingConstraint()
clears the supporting constraint
SqlUtil::cop_as
hash cop_as(any column, string arg)
returns a hash for the &quot;as&quot; operator with the given argument
SqlUtil::AbstractDatabase::getSchemaDescriptionOptions
private hash getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
SqlUtil::AbstractFunctionBase::getType
string getType()
returns the type of object
SqlUtil::Database::methodGate
any methodGate(string meth)
executes a method on the contained AbstractDatabase object
SqlUtil::AbstractTable::getAddCheckConstraintSql
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
SqlUtil::AbstractView::getRenameSql
abstract softlist getRenameSql(string new_name)
returns a list with command(s) that can be used to rename the view in the database ...
SqlUtil::cop_year_month
hash cop_year_month(any column)
returns a hash for the &quot;year_month&quot; operator with the given argument
SqlUtil::AbstractTable::getAlignSql
list getAlignSql(AbstractTable t, *hash opt)
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure a...
SqlUtil::AbstractConstraint::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
SqlUtil::Table::getDropTriggerSql
list getDropTriggerSql(string tname, *hash opt)
returns SQL that can be used to drop the given trigger from the table
SqlUtil::AbstractTable::constructor
private constructor(AbstractDatasource nds, string nname, *hash nopts)
creates the object; private constructor
SqlUtil::Table::truncate
truncate()
truncates all the table data; releases the transaction lock after executing
SqlUtil::AbstractFunctionBase::name
string name
the name of the object
Definition: SqlUtil.qm.dox.h:4254
SqlUtil::AbstractTable::getAlignSqlString
string getAlignSqlString(AbstractTable t, *hash opt)
accepts an AbstractTable argument and returns an SQL string that could be executed to align the struc...
SqlUtil::Table::dropColumn
AbstractColumn dropColumn(string cname, *reference lsql)
drops a column 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
SqlUtil::ForeignConstraintTarget
a class describing a foreign constraint target
Definition: SqlUtil.qm.dox.h:4125
SqlUtil::Table::getAlignSqlString
string getAlignSqlString(AbstractTable table, *hash opt)
accepts an AbstractTable argument and returns an SQL string that could be executed to align the struc...
SqlUtil::AbstractTable::getCreateIndexesSql
*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 a...
SqlUtil::AbstractDatabase::getDropFunctionSqlIfExists
*string getDropFunctionSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given function if it exists or NOTHING if the named function does...
SqlUtil::AbstractColumn::qore_type
*string qore_type
the equivalent qore type name of the column if known
Definition: SqlUtil.qm.dox.h:3637
SqlUtil::Constraints::add
add(string k, AbstractConstraint val)
adds the given value to the hash with the given key name
SqlUtil::op_gt
hash op_gt(any arg)
returns a hash for the &quot;&gt;&quot; operator with the given argument for use in where clauses when comparing c...
SqlUtil::Table::getConstraints
Constraints getConstraints()
returns a Constraints object describing non-foreign constraints on the table
SqlUtil::NumericColumnInfo
the base class to use to extend AbstractColumn to implement numeric columns
Definition: SqlUtil.qm.dox.h:3733
SqlUtil::Table::renameIndex
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 ...
SqlUtil::AbstractIndex::getRecreateSql
list getRecreateSql(AbstractDatasource ds, string table_name, *hash opt)
returns a list of strings to drop and recreate the current index; if there are dependent constraints...
SqlUtil::AbstractDatabase::AC_Create
const AC_Create
used when a new object is created
Definition: SqlUtil.qm.dox.h:4957
SqlUtil::Functions::add
add(string k, AbstractFunction val)
adds the given value to the hash with the given key name
True
const True
SqlUtil::Table::getAddUniqueConstraintSql
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
SqlUtil::Triggers::memberGate
AbstractTrigger memberGate(string k)
returns the AbstractTrigger object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::Database::listViews
list listViews()
returns a list of string view names in the database
SqlUtil::Table::rowCount
softint rowCount()
returns the number of rows in the table
SqlUtil::Table::getCreatePrimaryKeySql
*string getCreatePrimaryKeySql(*hash opt)
returns an SQL string that could be used to create the primary key on the table
SqlUtil::AbstractTable::getQoreTypeMapImpl
abstract private hash getQoreTypeMapImpl()
returns the qore type -&gt; column type map
SqlUtil::AbstractHashContainer::keys
list keys()
Returns a list of key names of the contained hash.
SqlUtil::AbstractTable::addForeignConstraint
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...
SqlUtil::JopMap
const JopMap
a hash of valid column operators
Definition: SqlUtil.qm.dox.h:2264
SqlUtil::make_op
hash make_op(string op, any arg)
returns a hash with op and arg keys
SqlUtil::SZ_MAND
const SZ_MAND
the data type takes a mandatory size parameter
Definition: SqlUtil.qm.dox.h:1645
SqlUtil::OP_GT
const OP_GT
the SQL greater than operator (&gt;) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2592
SqlUtil::CHAR
const CHAR
specifies a CHAR column
Definition: SqlUtil.qm.dox.h:1628
SqlUtil::op_clt
hash op_clt(string arg)
returns a hash for the &quot;&lt;&quot; operator with the given argument for use in where clauses when comparing t...
SqlUtil::COP_AVG
const COP_AVG
to return the average value
Definition: SqlUtil.qm.dox.h:1706
SqlUtil::DB_SEQUENCES
const DB_SEQUENCES
Feature: sequences.
Definition: SqlUtil.qm.dox.h:1607
SqlUtil::DB_MVIEWS
const DB_MVIEWS
Feature: materialized views/snapshots.
Definition: SqlUtil.qm.dox.h:1601
SqlUtil::Table::del
int del(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; the transacti...
SqlUtil::Table::getAddTriggerSql
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
SqlUtil::AbstractTable::clearImpl
private clearImpl()
clears any driver-specific table information
SqlUtil::JOP_LEFT
const JOP_LEFT
for left outer joins
Definition: SqlUtil.qm.dox.h:2256
SqlUtil::AbstractSequence
base class for sequences
Definition: SqlUtil.qm.dox.h:4180
SqlUtil::AbstractTable::getCreateTriggersSql
*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 ...
SqlUtil::Database::listFunctions
list listFunctions()
returns a list of string function names in the database
SqlUtil::op_cgt
hash op_cgt(string arg)
returns a hash for the &quot;&gt;&quot; operator with the given argument for use in where clauses when comparing t...
SqlUtil::AbstractTable::getColumnOperatorMap
private hash getColumnOperatorMap()
returns the column operator map for this object
SqlUtil::Indexes::getElementName
string getElementName()
must return the name of the contained element
SqlUtil::AbstractListContainer::add
add(any val)
adds the given value to the list
SqlUtil::AbstractDatabase::getSequence
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
SqlUtil::AbstractHashContainer::getElementName
abstract string getElementName()
must return the name of the contained element
SqlUtil::AbstractTable::updateNoCommit
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 tr...
SqlUtil::Columns::subset
Columns subset(softlist l)
returns a subset of the current columns according to the list argument
flush
nothing flush()
SqlUtil::AbstractColumn::nullable
bool nullable
True if the column can hold a NULL value, False if not
Definition: SqlUtil.qm.dox.h:3643
SqlUtil::cop_min
hash cop_min(any column)
returns a hash for the &quot;min&quot; operator; returns minimum column values
SqlUtil::AbstractTable::addPrimaryKey
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
SqlUtil::AbstractTable::UpsertOptions
const UpsertOptions
default upsert option keys
Definition: SqlUtil.qm.dox.h:8332
number
number number(softnumber n)
SqlUtil::COP_DISTINCT
const COP_DISTINCT
to return distinct values
Definition: SqlUtil.qm.dox.h:1691
SqlUtil::COP_YEAR_HOUR
const COP_YEAR_HOUR
to return a date value with year to hextern information
Definition: SqlUtil.qm.dox.h:1756
SqlUtil::AbstractTable::CacheOptions
const CacheOptions
default cache options
Definition: SqlUtil.qm.dox.h:8187
SqlUtil::AbstractDatabase::makeFunction
AbstractFunction makeFunction(string name, string src, *hash opts)
creates a database-specific AbstractFunction object corresponding to the arguments ...
SqlUtil::AbstractTable::describe
Columns describe()
returns an object of class Columns describing the table
SqlUtil::AbstractTable::getAddTriggerSql
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
SqlUtil::Database::getTable
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found ...
SqlUtil::Tables::getDropAllForeignConstraintsOnTableSql
*list getDropAllForeignConstraintsOnTableSql(string name, *hash opt)
returns a list of SQL strings that can be used to drop all the foreign constraints on a particular ta...
SqlUtil::AbstractTable::update
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 t...
SqlUtil::AbstractTable::foreignConstraints
ForeignConstraints foreignConstraints
foreign constraints description
Definition: SqlUtil.qm.dox.h:8465
SqlUtil::AbstractTable::native_case
bool native_case
native case option
Definition: SqlUtil.qm.dox.h:8471
SqlUtil::AbstractIndex::constraint
*AbstractUniqueConstraint constraint
the AbstractUniqueConstraint that this index supports, if any
Definition: SqlUtil.qm.dox.h:3810
SqlUtil::AbstractTable::getTruncateSql
string getTruncateSql(*hash opt)
gets the SQL that can be used to truncate the table
SqlUtil::AbstractTable::renameConstraint
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...
SqlUtil::AbstractTable::getDropAllConstraintsAndIndexesOnColumnSql
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 col...
SqlUtil::AbstractTable::getUpdateOperatorMap
private hash getUpdateOperatorMap()
returns the update operator map for this object
SqlUtil::AbstractDatabase::dropSequenceIfExists
bool dropSequenceIfExists(string name, *hash opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not ...
SqlUtil::Table::getRowIterator
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql)
returns an SQLStatement object that will iterate the results of a select statement matching the argum...
SqlUtil::Table::getSelectSql
string getSelectSql(*hash sh, *reference args)
returns the SQL string to be executed corresponding to the argument hash with an output parameter for...
SqlUtil::AbstractTable::getDropPrimaryKeySql
list getDropPrimaryKeySql(*hash opt)
gets a list of SQL strings that can be used to drop the primary key from the table ...
SqlUtil::Functions::take
AbstractFunction take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::op_cne
hash op_cne(string arg)
returns a hash for the &quot;!=&quot; or &quot;&lt;&gt;&quot; operator with the given argument for use in where clauses when co...
SqlUtil::Table::create
create(*hash opt)
creates the table in the database; releases the transaction lock after creating the table ...
SqlUtil::AbstractTable::addTrigger
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...
List
const List
SqlUtil::AbstractSqlUtilBase
base class for abstract SqlUtil classes
Definition: SqlUtil.qm.dox.h:4866
SqlUtil::AbstractDatabase::CacheOptions
const CacheOptions
generic cache options
Definition: SqlUtil.qm.dox.h:4929
SqlUtil::AbstractTable::UpsertUpdateFirst
const UpsertUpdateFirst
Upsert option: update first, if the update fails, then insert.
Definition: SqlUtil.qm.dox.h:8376
SqlUtil::AbstractSqlUtilBase::constructor
private constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
SqlUtil::AbstractTable::tryInsertImpl
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
SqlUtil::AbstractTable::del
int del(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; the transacti...
SqlUtil::AbstractTable::getAddColumnSql
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
NULL
const NULL
SqlUtil::AbstractDatabase::AC_Modify
const AC_Modify
used when an object is modified in place
Definition: SqlUtil.qm.dox.h:4966
SqlUtil::Columns::equal
bool equal(Columns cols)
returns True if the argument has the same columns in the same order as the current object...
SqlUtil::Table::upsertFromSelectNoCommit
*hash upsertFromSelectNoCommit(AbstractTable src, *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 curre...
SqlUtil::AbstractTable::create
create(*hash opt)
creates the table in the database; releases the transaction lock after creating the table ...
SqlUtil::OP_CNE
const OP_CNE
the SQL not equals operator (!= or &lt;&gt;) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2632
SqlUtil::AbstractHashContainer::memberGate
any memberGate(string k)
returns the value of the given key in the contained hash if it exists, otherwise throws a KEY-ERROR e...
SqlUtil::Database
represents a database; this class embeds an AbstractDatabase object that is created automatically in ...
Definition: SqlUtil.qm.dox.h:4417
SqlUtil::AbstractTable::insertFromIteratorNoCommit
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
SqlUtil::AbstractTable::doSelectLimitOnlyUnlockedImpl
abstract private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh)
processes a string for use in SQL select statements when there is a &quot;limit&quot; argument, but no &quot;orderby&quot; or &quot;offset&quot; arguments
SqlUtil::Table::constructor
constructor(AbstractDatasource ds, string name, *hash opts)
creates the Table object
SqlUtil::AbstractTable::getSqlDataCallbackOptions
private hash getSqlDataCallbackOptions()
returns the sql data operation callback options for this driver
SqlUtil::OP_CGT
const OP_CGT
the SQL greater than operator (&gt;) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2622
SqlUtil::Database::dropSequenceIfExists
bool dropSequenceIfExists(string name, *hash opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not ...
SqlUtil::AbstractForeignConstraint
the base class for foreign key constraint information
Definition: SqlUtil.qm.dox.h:4147
SqlUtil::op_like
hash op_like(string str)
returns a hash for the &quot;like&quot; operator with the given argument for use in where clauses ...
SqlUtil::AbstractForeignConstraint::target
ForeignConstraintTarget target
a ForeignConstraintTarget object to describe the target table and columns
Definition: SqlUtil.qm.dox.h:4155
SqlUtil::AbstractDatabase::getFunction
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
False
const False
SqlUtil::AbstractCheckConstraint::setIndexBase
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
SqlUtil::AbstractCheckConstraint::constructor
constructor(string n, string n_src)
creates the object and sets its name and the check clause source
SqlUtil::Constraints::memberGate
AbstractConstraint memberGate(string k)
returns the AbstractConstraint object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::AbstractSqlUtilBase::l
Mutex l()
mutex for atomic actions
SqlUtil::AbstractTable::copyImpl
abstract private copyImpl(AbstractTable old)
db-specific copy actions
SqlUtil::AbstractTable::getAddUniqueConstraintSql
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
NothingType
const NothingType
SqlUtil::op_lt
hash op_lt(any arg)
returns a hash for the &quot;&lt;&quot; operator with the given argument for use in where clauses when comparing c...
SqlUtil::AbstractUniqueConstraint::getCreateSql
abstract string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint in the database
SqlUtil::op_le
hash op_le(any arg)
returns a hash for the &quot;&lt;=&quot; operator with the given argument for use in where clauses when comparing ...
SqlUtil::Database::getView
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view
SqlUtil::Table::addCheckConstraint
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
Qore::SQL::AbstractDatasource
SqlUtil::NumericColumnInfo::scale
int scale
the scale for numeric columns
Definition: SqlUtil.qm.dox.h:3738
SqlUtil::Table::tryExec
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::AbstractCheckConstraint
abstract class for check constraints
Definition: SqlUtil.qm.dox.h:3969
SqlUtil::Table::renameConstraint
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...
SqlUtil::Table::emptyData
bool emptyData()
returns True if the table has no data rows, False if not
SqlUtil::Database::sequenceIterator
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
SqlUtil::AbstractDatabase::AC_Drop
const AC_Drop
used when an object is dropped
Definition: SqlUtil.qm.dox.h:4960
SqlUtil::AbstractFunctionBase::equal
bool equal(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractIndex::constructor
constructor(string n, bool u, hash c)
creates the object from the name, a unique flag, and a hash of column information ...
SqlUtil::COP_COUNT
const COP_COUNT
to return the row count
Definition: SqlUtil.qm.dox.h:1711
SqlUtil::Table::createNoCommit
createNoCommit(*hash opt)
creates the table with all associated properties (indexes, constraints, etc) without any transaction ...
list
list list(...)
SqlUtil::AbstractTable::getCreateSql
list getCreateSql(*hash opt)
returns a list of SQL strings that could be used to create the table and all known properties of the ...
SqlUtil::Database::getNextSequenceValue
int getNextSequenceValue(string name)
returns the next value in the given sequence
SqlUtil::OP_CEQ
const OP_CEQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2637
SqlUtil::AbstractHashContainer
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:3030
SqlUtil::Table::tryExecRaw
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
SqlUtil::AbstractTable::empty
bool empty()
returns True if the table has no definitions, False if not
SqlUtil::cop_distinct
hash cop_distinct(any column)
returns a hash for the &quot;distinct&quot; operator with the given argument; returns distinct column values ...
SqlUtil::AbstractDatabase::sequenceIterator
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
SqlUtil::AbstractDatabase::ActionLetterMap
const ActionLetterMap
maps from action codes to action letter codes
Definition: SqlUtil.qm.dox.h:5023
SqlUtil::AbstractTable::name
string name
the table&#39;s name
Definition: SqlUtil.qm.dox.h:8457
SqlUtil::AbstractTable::supportsTablespacesImpl
abstract private bool supportsTablespacesImpl()
returns True if the database support tablespaces
SqlUtil::AbstractDatabase::supportsPackages
bool supportsPackages()
returns True if the database supports packages
SqlUtil::AbstractTable::getAddIndexSql
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
SqlUtil::Triggers
trigger container class that throws an exception if an unknown trigger is accessed ...
Definition: SqlUtil.qm.dox.h:4369
SqlUtil::AbstractUniqueConstraint::renameSourceConstraintTable
renameSourceConstraintTable(string old_name, string new_name)
renames a table in a source constraint
SqlUtil::AbstractTable::dropTrigger
AbstractTrigger dropTrigger(string tname, *reference sql)
drops the given trigger from the table; if the table is known to be in the database already...
SqlUtil::DefaultUopMap
const DefaultUopMap
a hash of valid update operators
Definition: SqlUtil.qm.dox.h:2153
index
int index(softstring str, softstring substr, softint pos=0)
SqlUtil::AbstractCheckConstraint::src
string src
the source of the check clause
Definition: SqlUtil.qm.dox.h:3974
SqlUtil::AbstractSqlUtilBase::getDatasourceDesc
string getDatasourceDesc()
returns a descriptive string for the datasource
SqlUtil::AbstractTable::indexes
Indexes indexes
index descriptions
Definition: SqlUtil.qm.dox.h:8463
SqlUtil::AbstractDatabase::getDropSequenceSqlIfExists
*string getDropSequenceSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given sequence if it exists or NOTHING if the named sequence does...
SqlUtil::Database::getSqlFromList
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
Qore::SQL::SQLStatement
SqlUtil::AbstractDatabase::getDropSchemaOptions
private hash getDropSchemaOptions()
override in subclasses to return driver-specific options
SqlUtil::DB_PACKAGES
const DB_PACKAGES
Feature: packages.
Definition: SqlUtil.qm.dox.h:1603
SqlUtil::Columns::take
AbstractColumn take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::Table::upsertFromSelect
*hash upsertFromSelect(AbstractTable src, *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 curre...
SqlUtil::AbstractDatabase::listProcedures
list listProcedures()
returns a list of string procedure names in the database
SqlUtil::COP_UPPER
const COP_UPPER
to return column value in upper case
Definition: SqlUtil.qm.dox.h:1681
SqlUtil::AbstractDatabase::functionIterator
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
SqlUtil::COP_PLUS
const COP_PLUS
the SQL &quot;minus&quot; operator
Definition: SqlUtil.qm.dox.h:1726
SqlUtil::AbstractTable::getSelectOptions
private hash getSelectOptions()
returns the select options for this driver
Boolean
const Boolean
SqlUtil::AbstractFunctionBase::equalImpl
abstract private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
SqlUtil::cop_minus
hash cop_minus(any column1, any column2)
returns a hash for the &quot;-&quot; operator with the given arguments
SqlUtil::Table::cache
cache(*hash opts)
reads in all attributes of the table from the database
SqlUtil::AbstractTable::UR_Verified
const UR_Verified
row was updated unconditionally (not returned with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8410
SqlUtil::AbstractDatabase::supportsSequencesImpl
abstract private bool supportsSequencesImpl()
returns True if the database supports sequences
SqlUtil::AbstractTable::clear
clear()
purges the current table definition
SqlUtil::OP_GE
const OP_GE
the SQL greater than or equals operator (&gt;=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2597
SqlUtil::Indexes
index container class that throws an exception if an unknown index is accessed
Definition: SqlUtil.qm.dox.h:3751
SqlUtil::AbstractTable::validateColumnOptions
private validateColumnOptions(string cname, reference opt, bool nullable)
validates column options
SqlUtil::SZ_NUM
const SZ_NUM
the data type is numeric so takes an optional precision and scale
Definition: SqlUtil.qm.dox.h:1651
SqlUtil::AbstractTable::constraintsLinkedToIndexesImpl
abstract private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
SqlUtil::Database::tableIterator
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
SqlUtil::Table::addUniqueConstraint
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...
SqlUtil::AbstractTable::TableOptions
const TableOptions
table options
Definition: SqlUtil.qm.dox.h:8166
SqlUtil::AbstractTable::tryExecArgs
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::AbstractDatabase::AC_Rename
const AC_Rename
used when an object is renamed
Definition: SqlUtil.qm.dox.h:4963
SqlUtil::Table::getIndexes
Indexes getIndexes()
returns an object of class Indexes describing the indexes on the table
SqlUtil::AbstractIndex::equalImpl
abstract bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
SqlUtil::AbstractTable::getTableColumnDescOptions
private hash getTableColumnDescOptions()
returns the table column description options for this driver
SqlUtil::AbstractColumn::getCreateSql
string getCreateSql()
returns an sql string that can be used to add the column to a table
SqlUtil::AbstractTable::upsertFromSelect
*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 curre...
SqlUtil::AbstractDatabase::getAlignSql
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
SqlUtil::AbstractTable::getForeignConstraints
ForeignConstraints getForeignConstraints(*hash opt)
returns a ForeignConstraints object describing the foreign constraints that the table has on other ta...
SqlUtil::Table::getRenameSql
string getRenameSql(string new_name, *hash opt)
returns an SQL string that could be used to rename the table in the database
SqlUtil::AbstractDatabase::tryExecArgs
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::Table::tryExecArgs
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::AbstractColumn::def_val
*string def_val
default value for column
Definition: SqlUtil.qm.dox.h:3646
SqlUtil::AbstractTable::insertFromIterator
int insertFromIterator(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
SqlUtil::AbstractTable::primaryKey
AbstractPrimaryKey primaryKey
primary key description
Definition: SqlUtil.qm.dox.h:8461
SqlUtil::AbstractTable::tryExecRaw
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
SqlUtil::Table::insertNoCommit
insertNoCommit(hash row, *reference sql)
inserts a row into the table without any transaction management; a transaction will be in progress af...
SqlUtil::Table::addPrimaryKey
AbstractPrimaryKey addPrimaryKey(string cname, softlist cols, *hash opt, *reference sql)
adds a primary key to the table; if the table already exists, then it is added in the database also i...
SqlUtil::cop_plus
hash cop_plus(any column1, any column2)
returns a hash for the &quot;+&quot; operator with the given arguments
SqlUtil::Table::getAddCheckConstraintSql
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
SqlUtil::AbstractTable::manual
bool manual
manual edits
Definition: SqlUtil.qm.dox.h:8475
SqlUtil::AbstractTable::AlignTableOptions
const AlignTableOptions
table alignment options
Definition: SqlUtil.qm.dox.h:8255
SqlUtil::AbstractTable::getPrimaryKey
AbstractPrimaryKey getPrimaryKey()
returns an object of class AbstractPrimaryKey describing the primary key of the table ...
SqlUtil::Indexes::findEqual
*AbstractIndex findEqual(AbstractIndex ix)
find an index with columns equal to the index passed
SqlUtil::AbstractTable::emptyData
bool emptyData()
returns True if the table has no data rows, False if not
SqlUtil::Tables::tableRenamed
bool tableRenamed(string old_name, string new_name, string old_sql_name)
updates table names and internal references for renamed tables
SqlUtil::AbstractUniqueConstraint::removeSourceConstraint
removeSourceConstraint(string tname, list cols)
removes a source constraint
SqlUtil::Database::tryExecRaw
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
SqlUtil::AbstractConstraint::getCreateSql
abstract string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
SqlUtil::Table::addColumn
AbstractColumn addColumn(string cname, hash opt, bool nullable=True, *reference lsql)
adds a column to the table; if the table already exists, then it is added in the database also immedi...
SqlUtil::Table::upsertNoCommit
int upsertNoCommit(hash row, int upsert_strategy=AbstractTable::UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
SqlUtil::AbstractTable::getCreateForeignConstraintsSql
*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 NOTHIN...
SqlUtil::NumericColumnInfo::getNativeTypeString
string getNativeTypeString(string native_type, int precision)
returns the string describing the native type that can be used in SQL (for example to add the column ...
SqlUtil::AbstractUniqueConstraint::getDisableReenableSql
hash getDisableReenableSql(AbstractDatasource ds, string table_name, *hash opts)
returns lists of SQL strings to disable this constraint plus any dependent constraints and another li...
SqlUtil::cop_lower
hash cop_lower(any column)
returns a hash for the &quot;lower&quot; operator with the given argument; returns a column value in lower case...
SqlUtil::AbstractTable::triggers
Triggers triggers
trigger descriptions
Definition: SqlUtil.qm.dox.h:8469
SqlUtil::Tables::getRenameTableIfExistsSql
*string getRenameTableIfExistsSql(string old_name, string new_name, *hash opts)
returns an SQL string that can be used to rename the given table if it exists and the target does not...
SqlUtil::Table::describe
Columns describe()
returns an object of class Columns describing the Table
SqlUtil::DB_PROCEDURES
const DB_PROCEDURES
Feature: procedures.
Definition: SqlUtil.qm.dox.h:1605
SqlUtil::AbstractDatabase::CreationOptions
const CreationOptions
default generic creation options
Definition: SqlUtil.qm.dox.h:5045
SqlUtil::AbstractColumn::getRenameSql
abstract string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
SqlUtil::Tables::memberGate
AbstractTable memberGate(string k)
returns the AbstractTable object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::OP_EQ
const OP_EQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2607
SqlUtil::AbstractConstraint::getEnableSql
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database; if disabling constraints ...
SqlUtil::Database::getSequence
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
SqlUtil::AbstractTable::getDropColumnSql
list getDropColumnSql(string cname, *hash opt)
returns the SQL that can be used to drop a column from the table
SqlUtil::Table::getPrimaryKey
AbstractPrimaryKey getPrimaryKey()
returns an object of class AbstractPrimaryKey describing the primary key of the table ...
SqlUtil::AbstractDatabase::dropViewIfExists
bool dropViewIfExists(string name, *hash opt)
drops the given view if it exists; returns True if the view was dropped, False if not ...
exists
bool exists(...)
SqlUtil::ForeignConstraints::take
AbstractForeignConstraint take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::AbstractConstraint::equalImpl
abstract private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractListContainer::getElementName
abstract string getElementName()
must return the name of the contained element
SqlUtil::AbstractColumn::comment
*string comment
comment on the column
Definition: SqlUtil.qm.dox.h:3649
SqlUtil::Tables::dropIterator
Qore::AbstractIterator dropIterator()
returns an iterator for a list of cached table names in the order that can be used to drop the tables...
SqlUtil::AbstractUniqueConstraint::getSourceConstraintIterator
Qore::AbstractIterator getSourceConstraintIterator()
returns an iterator through all known source foreign constraints on the current table ...
SqlUtil::Database::getAlignFunctionSql
list getAlignFunctionSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a function in the database to the function d...
SqlUtil::Table::dropIndex
AbstractIndex dropIndex(string iname, *reference sql)
drops the 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
SqlUtil::Table::getName
string getName()
returns the name of the table
SqlUtil::Table::getUpsertClosure
code getUpsertClosure(hash example_row, int upsert_strategy=AbstractTable::UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
SqlUtil::AbstractListContainer::val
bool val()
Returns False if the contained list is empty, True if not.
SqlUtil::AbstractTable::getSelectSql
string getSelectSql(*hash sh, *reference args)
returns the SQL string to be executed corresponding to the argument hash with an output parameter for...
SqlUtil::AbstractView::src
string src
the source code
Definition: SqlUtil.qm.dox.h:4225
SqlUtil::AbstractIndex::unique
bool unique
True if the index is a unique index, False if not
Definition: SqlUtil.qm.dox.h:3801
SqlUtil::AbstractTable::getDropIndexSql
string getDropIndexSql(string iname, *hash opt)
gets the SQL that can be used to drop an index from the table
SqlUtil::AbstractColumn::getModifySql
list getModifySql(AbstractTable t, AbstractColumn c, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
SqlUtil::cop_over
hash cop_over(any column, string arg)
returns a hash for the &quot;over&quot; clause
SqlUtil::Table::getDatasource
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
SqlUtil::AbstractDatabase::AC_Insert
const AC_Insert
used when data is inserted in a table
Definition: SqlUtil.qm.dox.h:4978
SqlUtil::Database::tryExec
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::Tables::add
add(string k, Table val)
adds the given value to the hash with the given key name
SqlUtil::Database::viewIterator
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
SqlUtil::Database::constructor
constructor(AbstractDatasource ds, *hash opts)
creates the Database object
SqlUtil::AbstractColumn::getNativeTypeString
string getNativeTypeString()
returns the string describing the native type that can be used in SQL (for example to add the colunn ...
SqlUtil::AbstractHashContainer::iterator
Qore::AbstractIterator iterator()
Returns a HashIterator object for the contained hash.
SqlUtil::AbstractTable::tryExecRawImpl
private any tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
SqlUtil::AbstractDatabase::tableIterator
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
SqlUtil::AbstractTable::getAddForeignConstraintSql
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
SqlUtil::Table::getCreateSql
list getCreateSql(*hash opt)
returns a list of SQL strings that could be used to create the table and all known properties of the ...
SqlUtil::AbstractTable::getSqlName
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
SqlUtil::COP_YEAR_MONTH
const COP_YEAR_MONTH
to return a date value with year to month information
Definition: SqlUtil.qm.dox.h:1746
SqlUtil::AbstractFunctionBase::src
string src
the source of the object
Definition: SqlUtil.qm.dox.h:4260
SqlUtil::AbstractUniqueConstraint::equalImpl
private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
SqlUtil::Triggers::getElementName
string getElementName()
must return the name of the contained element
SqlUtil::AbstractTable::getForeignConstraintOptions
private hash getForeignConstraintOptions()
return the foreign constraint options for this driver
SqlUtil::COP_MAX
const COP_MAX
to return the maximum value
Definition: SqlUtil.qm.dox.h:1701
SqlUtil::AbstractTable::dropForeignConstraint
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql)
drops a foreign constraint from the table; if the table is known to be in the database already...
SqlUtil::Table::insert
insert(hash row, *reference sql)
inserts a row into the table; the transaction is committed if successful, if an error occurs...
SqlUtil::COP_AS
const COP_AS
to rename a column on output
Definition: SqlUtil.qm.dox.h:1661
SqlUtil::AbstractSqlUtilBase::getDriverName
string getDriverName()
returns the database driver name
SqlUtil::cop_divide
hash cop_divide(any column1, any column2)
returns a hash for the &quot;/&quot; operator with the given arguments
SqlUtil::op_ge
hash op_ge(any arg)
returns a hash for the &quot;&gt;=&quot; operator with the given argument for use in where clauses when comparing ...
SqlUtil::AbstractConstraint::getRenameSql
abstract list getRenameSql(string table_name, string new_name)
returns a list of SQL strings that can be used to rename the constraint in the database ...
SqlUtil::AbstractTable::columns
Columns columns
column description object
Definition: SqlUtil.qm.dox.h:8459
SqlUtil::Table::insertFromSelectNoCommit
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 sam...
SqlUtil::AbstractDatabase::constructor
private constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
SqlUtil::Database::getFunction
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
SqlUtil::DB_VIEWS
const DB_VIEWS
Feature: views.
Definition: SqlUtil.qm.dox.h:1613
SqlUtil::op_not
hash op_not(hash arg)
returns a hash for the &quot;not&quot; operator; for use in where clauses
SqlUtil::Database::procedureIterator
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
SqlUtil::Table::addForeignConstraint
AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql)
adds an foreign constraint to the table; if the table is already known to be in the database...
SqlUtil::OP_LE
const OP_LE
the SQL less than or equals (&lt;=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2587
SqlUtil::AbstractDatabase::getCacheOptions
private hash getCacheOptions()
override in subclasses to return driver-specific options
SqlUtil::BLOB
const BLOB
specifies a large variable-length binary column (ie BLOB or BYTEA, etc)
Definition: SqlUtil.qm.dox.h:1631
SqlUtil::AbstractIndex::name
string name
the name of the index
Definition: SqlUtil.qm.dox.h:3798
SqlUtil::Table::insertFromIterator
int insertFromIterator(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
type
string type(any arg)
SqlUtil::cop_value
hash cop_value(any arg)
returns a hash for the &quot;value&quot; operator with the given argument
SqlUtil::AbstractTable::dropConstraint
AbstractConstraint dropConstraint(string cname, *reference sql)
drops a constraint from the table; this can be any constraint on the table, a primary key...
SqlUtil::AbstractTable::getCreatePrimaryKeySql
*string getCreatePrimaryKeySql(*hash opt, bool cache=True)
returns an SQL string that could be used to create the primary key on the table
SqlUtil::ForeignConstraintTarget::columns
Columns columns
columns in the target table
Definition: SqlUtil.qm.dox.h:4133
SqlUtil::AbstractTable::drop
drop(*hash opt)
drops the table from the database; releases the transaction lock after dropping the table ...
SqlUtil::OP_CLE
const OP_CLE
the SQL less than or equals (&lt;=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2617
SqlUtil::join_left
hash join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for left outer joins with the given arguments
SqlUtil::AbstractTable::addColumn
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 ...
SqlUtil::Table::modifyColumn
AbstractColumn modifyColumn(string cname, hash opt, bool nullable=True, *reference lsql)
modifies an existing column in the table; if the table already exists, then the changes are effected ...
SqlUtil::DB_TABLES
const DB_TABLES
Feature: tables.
Definition: SqlUtil.qm.dox.h:1609
SqlUtil::Database::getAlignProcedureSql
list getAlignProcedureSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a stored procedure in the database to the st...
SqlUtil::Constraints::getElementName
string getElementName()
must return the name of the contained element
SqlUtil::Table::select
*hash select(*hash sh, *reference sql)
returns a hash of lists representing the columns and rows in the table that match the argument hahs ...
SqlUtil::CLOB
const CLOB
specifies a large variable-length character column (ie CLOB or TEXT, etc)
Definition: SqlUtil.qm.dox.h:1634
SqlUtil::AbstractDatabase::getSqlFromList
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
SqlUtil::AbstractDatabase::supportsTypes
bool supportsTypes()
returns True if the database supports named types
SqlUtil::OP_NOT
const OP_NOT
the SQL &quot;not&quot; operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2652
SqlUtil::Table::renameColumn
AbstractColumn renameColumn(string old_name, string new_name, reference sql)
renames an existing column; if the table already exists, then the changes are effected in the databas...
SqlUtil::AbstractTable::getRenameSql
string getRenameSql(string new_name, *hash opt)
returns an SQL string that could be used to rename the table in the database
SqlUtil::AbstractHashContainer::clear
clear()
purges the contained data
SqlUtil::AbstractIndex::columns
Columns columns
an object of class Columns representing the columns in the index
Definition: SqlUtil.qm.dox.h:3804
SqlUtil::Table::getCreateConstraintsSql
*list getCreateConstraintsSql(*hash opt)
returns a list of SQL strings that could be used to create non-foreign constraints on the table or NO...
SqlUtil::ForeignConstraints::memberGate
AbstractForeignConstraint memberGate(string k)
returns the AbstractForeignConstraint object corresponding to the key given or throws a KEY-ERROR exc...
SqlUtil::AbstractTable::SqlDataCallbackOptions
const SqlDataCallbackOptions
generic SQL data operation callbacks
Definition: SqlUtil.qm.dox.h:8322
SqlUtil::AbstractFunctionBase
base class for function or objects with code
Definition: SqlUtil.qm.dox.h:4249
SqlUtil::DB_TYPES
const DB_TYPES
Feature: named types.
Definition: SqlUtil.qm.dox.h:1611
SqlUtil::AbstractUniqueConstraint::addSourceConstraint
addSourceConstraint(string tname, AbstractForeignConstraint fk)
adds a foreign constraint source to the unique constraint
SqlUtil::AbstractTable::getRenameColumnSql
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
SqlUtil::Database::makeTable
AbstractTable makeTable(string name, hash desc, *hash opts)
creates a database-specific AbstractTable object corresponding to the arguments
SqlUtil::AbstractListContainer::empty
bool empty()
returns True if the container is empty, False if not
SqlUtil::AbstractTable::copy
copy(AbstractTable old)
copies the object
SqlUtil::AbstractTable::getInsertOptions
private hash getInsertOptions()
returns the insert options for this driver
SqlUtil::AbstractDatabase::viewIterator
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
SqlUtil::Table::setDatasource
setDatasource(AbstractDatasource nds)
changes the datasource for the table; if the inDb flag is True, then it is set to False by calling th...
SqlUtil::Database::makeFunction
AbstractFunction makeFunction(string name, string src, *hash opt)
creates a database-specific AbstractFunction object corresponding to the arguments ...
SqlUtil::AbstractTable::UpsertResultMap
const UpsertResultMap
hash mapping upsert results to a description
Definition: SqlUtil.qm.dox.h:8425
SqlUtil::AbstractUniqueConstraint::findMatchingIndex
findMatchingIndex(*Indexes indexes)
find an index that matches the constraint and marks both objects as related
SqlUtil::AbstractDatabase::tryExecArgsImpl
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 ...
SqlUtil::AbstractColumn::name
string name
the name of the column
Definition: SqlUtil.qm.dox.h:3631
SqlUtil::AbstractHashContainer::empty
bool empty()
returns True if the container is empty, False if not
SqlUtil::Database::supportsSequences
bool supportsSequences()
returns True if the database supports sequences
SqlUtil::AbstractDatabase::getAlignSchemaOptions
private hash getAlignSchemaOptions()
override in subclasses to return driver-specific options
string
string string(softstring str)
SqlUtil::AbstractTable::getConstraintOptions
private hash getConstraintOptions()
returns the constraint options for this driver
SqlUtil::AbstractSqlUtilBase::ds
AbstractDatasource ds
the connection to the database server
Definition: SqlUtil.qm.dox.h:4871
SqlUtil::AbstractConstraint::getName
string getName()
returns the constraint name
SqlUtil::AbstractTable::insert
insert(hash row, *reference sql)
inserts a row into the table; the transaction is committed if successful, if an error occurs...
SqlUtil::Table::getCreateMiscSql
*list getCreateMiscSql(*hash opt)
returns a list of SQL strings that could be used to create other table attributes (such as comments...
SqlUtil::AbstractColumn::getModifySqlImpl
abstract private list getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
SqlUtil::AbstractIndex::getName
string getName()
returns the index name
SqlUtil::AbstractFunction
base class for functions
Definition: SqlUtil.qm.dox.h:4290
SqlUtil::AbstractTable::getTableDescriptionHashOptions
private hash getTableDescriptionHashOptions()
returns the table description hash options for this driver
SqlUtil::Table::getCreateSqlString
string getCreateSqlString(*hash opt)
returns an SQL string that could be used to create the table and all known properties of the table ...
SqlUtil::COP_MULTIPLY
const COP_MULTIPLY
the SQL &quot;multiply&quot; operator
Definition: SqlUtil.qm.dox.h:1736
SqlUtil::AbstractTable::addUniqueConstraint
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...
SqlUtil::AbstractDatabase::listSequences
list listSequences()
returns a list of string sequence names in the database
SqlUtil::AbstractTable::constraints
Constraints constraints
constraint descriptions
Definition: SqlUtil.qm.dox.h:8467
SqlUtil::COP_PREPEND
const COP_PREPEND
to prepend a string to a column on output
Definition: SqlUtil.qm.dox.h:1666
SqlUtil::Database::getDropSchemaSql
list getDropSchemaSql(hash schema_hash, *hash opt)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
SqlUtil::cop_count
hash cop_count(string column="")
returns a hash for the &quot;count&quot; operator; returns row counts
SqlUtil::Table::getDropConstraintSql
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 ...
SqlUtil::AbstractTable::getSqlFromList
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
SqlUtil::AbstractDatabase::listFunctions
list listFunctions()
returns a list of string function names in the database
SqlUtil::AbstractHashContainer::partialMatchKeys
bool partialMatchKeys(hash h1)
returns True if the hash argument has at least the same keys (in any order, can have more keys)...
SqlUtil::AbstractDatabase::makeSequence
AbstractSequence makeSequence(string name, number start=1, number increment=1, *softnumber end, *hash opts)
creates a database-specific AbstractSequence object corresponding to the arguments ...
SqlUtil::AbstractDatabase::AC_Recreate
const AC_Recreate
used when an object is recreated (usually dropped and recreated in place)
Definition: SqlUtil.qm.dox.h:4975
SqlUtil::AbstractUniqueConstraint::getIndex
*string getIndex()
returns the name of the associated index, if any
SqlUtil::AbstractConstraint::clearIndex
abstract clearIndex()
clears any index base for the constraint
SqlUtil::AbstractView
base class for views
Definition: SqlUtil.qm.dox.h:4214
SqlUtil::Database::dropTableIfExists
bool dropTableIfExists(string name, *hash opt)
drops the given table if it exists; returns True if the table was dropped, False if not ...
SqlUtil::AbstractHashContainer::hasKey
bool hasKey(string k)
Returns True if the key exists in the contained hash (may or may not be assigned a value)...
SqlUtil::AbstractIndex::equal
bool equal(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
SqlUtil::AbstractFunction::getRenameSql
abstract list getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
SqlUtil::AbstractSqlUtilBase::opts
*hash opts
option hash
Definition: SqlUtil.qm.dox.h:4877
SqlUtil::AbstractTable::getCreateSqlString
string getCreateSqlString(*hash opt)
returns an SQL string that could be used to create the table and all known properties of the table ...
SqlUtil::Table::getTable
AbstractTable getTable()
returns the AbstractTable object contained by this object
SqlUtil::AbstractDatabase::native_case
bool native_case
native case option
Definition: SqlUtil.qm.dox.h:5108
SqlUtil::AbstractTable::getCreateConstraintsSql
*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 NO...
SqlUtil::Table::getAddColumnSql
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
SqlUtil::AbstractDatabase::makeProcedure
AbstractFunction makeProcedure(string name, string src, *hash opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
SqlUtil::AbstractHashContainer::renameKey
renameKey(string old_name, string new_name)
renames the given key; maintains the key order
SqlUtil::AbstractTable::selectRow
*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...
SqlUtil::Table::getModifyColumnSql
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 ...
SqlUtil::AbstractTable::getTableCreationOptions
private hash getTableCreationOptions()
returns the table creation options for this driver
SqlUtil::AbstractTable::InsertOptions
const InsertOptions
default insert option keys
Definition: SqlUtil.qm.dox.h:8343
SqlUtil::Database::getDatasource
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
SqlUtil::Triggers::take
AbstractTrigger take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::AbstractColumn::equalImpl
abstract private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractDatabase::tryExecRaw
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
SqlUtil::Table::upsertFromIterator
*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 ret...
SqlUtil::AbstractTable::insertNoCommit
insertNoCommit(hash row, *reference sql)
inserts a row into the table without any transaction management; a transaction will be in progress af...
SqlUtil::AbstractTable::TriggerOptions
const TriggerOptions
default trigger options
Definition: SqlUtil.qm.dox.h:8202
SqlUtil::AbstractTable::findAll
*list findAll(*hash cond)
finds all rows in the table with the given column values; a list of hashes is returned representing t...
SqlUtil::cop_prepend
hash cop_prepend(any column, string arg)
returns a hash for the &quot;prepend&quot; operator with the given argument
SqlUtil::Table::dropForeignConstraint
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql)
drops the foreign constraint from the table; if the table is known to be in the database already...
SqlUtil::AbstractFunctionBase::type
string type
the type of object
Definition: SqlUtil.qm.dox.h:4257
SqlUtil::Table::setupTable
setupTable(hash desc, *hash opt)
creates the object from a table description hash
Int
const Int
SqlUtil::AbstractTable::renameIndex
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 ...
SqlUtil::AbstractTable::doSelectOrderByWithOffsetSqlUnlockedImpl
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 &quot;order by&quot; and &quot;offset&quot; argument...
SqlUtil::Table::findAll
*list findAll(*hash cond)
finds all rows in the table with the given column values; a list of hashes is returned representing t...
SqlUtil::COP_YEAR
const COP_YEAR
to return a date value with year information only
Definition: SqlUtil.qm.dox.h:1741
SqlUtil::AbstractListContainer::constructor
constructor(softlist nl)
creates the object with the list argument passed
SqlUtil::AbstractForeignConstraint::hasColumn
bool hasColumn(string cname)
returns True if the constraint references the named column
SqlUtil::Table::getTriggers
Triggers getTriggers()
returns an object of class Triggers describing the triggers on the table
SqlUtil::AbstractDatabase::SequenceDescriptionOptions
const SequenceDescriptionOptions
default generic sequence description keys
Definition: SqlUtil.qm.dox.h:5098
SqlUtil::AbstractTable::addCheckConstraint
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
SqlUtil::AbstractTrigger::getCreateSql
abstract list getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
SqlUtil::Table::getCreateIndexesSql
*list getCreateIndexesSql(*hash opt)
returns a list of SQL strings that could be used to create indexes on the table or NOTHING if there a...
SqlUtil::AbstractTable::rowCount
softint rowCount()
returns the number of rows in the table
SqlUtil::AbstractTable::rollback
rollback()
rolls back the current transaction on the underlying Qore::SQL::AbstractDatasource ...
SqlUtil::Tables::getElementName
string getElementName()
returns &quot;table&quot; since this object stores AbstractTable objects
SqlUtil::Table::getDropPrimaryKeySql
list getDropPrimaryKeySql(*hash opt)
gets a list of SQL strings that can be used to drop the primary key from the table ...
SqlUtil::AbstractTable::getTypeMapImpl
abstract private hash getTypeMapImpl()
returns the type name -&gt; type description hash
SqlUtil::AbstractView::getDropSql
string getDropSql()
returns a string that can be used to drop the view from the database
SqlUtil::Table::dropNoCommit
dropNoCommit(*hash opt)
drops the table from the database without any transaction management
SqlUtil::ForeignConstraints::getElementName
string getElementName()
returns &quot;foreign constraint&quot; for the type of object encapsulated
SqlUtil::AbstractColumn::size
int size
the size of the column
Definition: SqlUtil.qm.dox.h:3640
SqlUtil::AbstractTable::renameColumn
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...
SqlUtil::Table::getSqlFromList
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
SqlUtil::AbstractDatabase::dropTableIfExists
bool dropTableIfExists(string name, *hash opt)
drops the given table if it exists; returns True if the table was dropped, False if not ...
SqlUtil::Database::listProcedures
list listProcedures()
returns a list of string procedure names in the database
SqlUtil::AbstractTable::getModifyColumnSql
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 ...
SqlUtil::AbstractTable::getSqlValue
string getSqlValue(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
SqlUtil::AbstractHashContainer::size
int size()
Returns the number of keys in the contained hash.
SqlUtil::AbstractDatabase::tryExecRawImpl
private any tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
SqlUtil::AbstractHashContainer::keyIterator
Qore::AbstractIterator keyIterator()
Returns a HashKeyIterator object for the contained hash.
SqlUtil::AbstractTable::getWhereOperatorMap
private hash getWhereOperatorMap()
returns the &quot;where&quot; operator map for this object
SqlUtil::Table::upsertFromIteratorNoCommit
*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 ret...
SqlUtil::Database::tryExecArgs
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::AbstractSequence::getRenameSql
abstract string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
SqlUtil::AbstractColumn::native_type
string native_type
the native type name of the column
Definition: SqlUtil.qm.dox.h:3634
SqlUtil::COP_VALUE
const COP_VALUE
to append a constant value to use as an output column value
Definition: SqlUtil.qm.dox.h:1676
SqlUtil::AbstractTable::truncateNoCommit
truncateNoCommit()
truncates all the table data without any transaction management
SqlUtil::Columns
column container class that throws an exception if an unknown column is accessed
Definition: SqlUtil.qm.dox.h:3579
SqlUtil::AbstractTrigger
the base class for triggers
Definition: SqlUtil.qm.dox.h:4351
SqlUtil::join_right
hash join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for right outer joins with the given arguments
SqlUtil::op_eq
hash op_eq(any arg)
returns a hash for the &quot;=&quot; operator with the given argument for use in where clauses when comparing c...
SqlUtil::AbstractTable::getAlignTableOptions
private hash getAlignTableOptions()
returns the align table options for this driver
SqlUtil::Table::insertFromSelect
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 sam...
SqlUtil::OP_LT
const OP_LT
the SQL less than (&lt;) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2582
SqlUtil::AbstractSqlUtilBase::dsdesc
string dsdesc
datasource description
Definition: SqlUtil.qm.dox.h:4873
SqlUtil::AbstractTable::findSingle
*hash findSingle(*hash cond)
finds a single row in the table that match the row condition passed; multiple rows may match...
SqlUtil::AbstractTable::setDatasource
setDatasource(AbstractDatasource nds)
changes the datasource for the table; if the inDb flag is True, then it is set to False by calling th...
SqlUtil::Table::empty
bool empty()
returns True if the table has no definitions, False if not
SqlUtil::AbstractDatabase::AlignSchemaOptions
const AlignSchemaOptions
default generic schema description / alignment options
Definition: SqlUtil.qm.dox.h:5055
SqlUtil::ForeignConstraints::findConstraintOn
*hash findConstraintOn(string table, softlist cols)
returns either a hash of AbstractColumn information or NOTHING if no foreign constraint can be found ...
SqlUtil::ForeignConstraints::add
add(string k, AbstractForeignConstraint val)
adds the given value to the hash with the given key name
SqlUtil::Functions
function container class that throws an exception if an unknown function is accessed ...
Definition: SqlUtil.qm.dox.h:4313
SqlUtil::AbstractTable::getIndexes
Indexes getIndexes()
returns an object of class Indexes describing the indexes on the table
SqlUtil::AbstractTable::UR_Unchanged
const UR_Unchanged
row was unchanged (only possible with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8416
SqlUtil::AbstractTable::dropPrimaryKey
AbstractPrimaryKey dropPrimaryKey(*reference lsql)
drops the primary key from the table; if the table is known to be in the database already...
SqlUtil::Table::rename
rename(string new_name, *reference sql, *Tables table_cache)
renames the table; if the table already exists in the database, then the changes are effected in the ...
SqlUtil::AbstractTable::UR_Updated
const UR_Updated
row was updated because it was different (only possible with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8413
SqlUtil::AbstractDatabase::getNextSequenceValue
int getNextSequenceValue(string name)
returns the next value in the given sequence
SqlUtil::Database::db
AbstractDatabase db
the embedded AbstractDatabase object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:4422
SqlUtil::AbstractColumn
the base class for column information
Definition: SqlUtil.qm.dox.h:3626
SqlUtil::AbstractTable::truncate
truncate()
truncates all the table data; releases the transaction lock after executing
SqlUtil::AbstractUniqueConstraint::hasColumn
bool hasColumn(string cname)
returns True if the constraint references the named column
SqlUtil::AbstractTable::UpsertInsertOnly
const UpsertInsertOnly
Upsert option: insert if the row does not exist, otherwise ignore.
Definition: SqlUtil.qm.dox.h:8399
SqlUtil::AbstractFunction::setName
setName(string new_name)
sets the new name of the object
SqlUtil::join_inner
hash join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for standard inner joins with the given arguments
SqlUtil::Table::dropPrimaryKey
AbstractPrimaryKey dropPrimaryKey(*reference lsql)
drops the primary key from the table; if the table is known to be in the database already...
SqlUtil::Triggers::add
add(string k, AbstractTrigger val)
adds the given value to the hash with the given key name
SqlUtil::OP_CGE
const OP_CGE
the SQL greater than or equals operator (&gt;=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2627
SqlUtil::AbstractDatabase::AC_Truncate
const AC_Truncate
used when a table is truncated
Definition: SqlUtil.qm.dox.h:4969
SqlUtil::op_cle
hash op_cle(string arg)
returns a hash for the &quot;&lt;=&quot; operator with the given argument for use in where clauses when comparing ...
SqlUtil::AbstractTable::getName
string getName()
returns the name of the table
SqlUtil::Table
represents a database table; this class embeds an AbstractTable object that is created automatically ...
Definition: SqlUtil.qm.dox.h:5729
SqlUtil::AbstractTable::IndexOptions
const IndexOptions
default index options
Definition: SqlUtil.qm.dox.h:8176
SqlUtil::AbstractTable::getColumnOptions
private hash getColumnOptions()
returns the column options for this driver
SqlUtil::AbstractHashContainer::values
list values()
Returns a list of values of the contained hash.
SqlUtil::Table::dropConstraint
AbstractConstraint dropConstraint(string cname, *reference sql)
drops a constraint from the table; this can be any constraint on the table, a primary key...
SqlUtil::AbstractTable::find
*hash find(any id)
finds a row in the table with the given primary key value; if no row matches the primary key value pa...
SqlUtil::AbstractColumn::equal
bool equal(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
SqlUtil::AbstractTable::rename
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
SqlUtil::Tables::take
AbstractTable take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::make_cop
hash make_cop(string cop, any column, any arg)
returns a hash with cop, column, and arg keys
SqlUtil::COP_MIN
const COP_MIN
to return the minimum value
Definition: SqlUtil.qm.dox.h:1696
SqlUtil::AbstractTable::UpsertSelectFirst
const UpsertSelectFirst
Upsert option: select first, if the row is unchanged, do nothing, if it doesn&#39;t exist, insert, otherwise update.
Definition: SqlUtil.qm.dox.h:8385
SqlUtil::AbstractDatabase::dropFunctionIfExists
bool dropFunctionIfExists(string name, *hash opt)
drops the given function if it exists; returns True if the function was dropped, False if not ...
SqlUtil::COP_YEAR_DAY
const COP_YEAR_DAY
to return a date value with year to day information
Definition: SqlUtil.qm.dox.h:1751
SqlUtil::AbstractTable::dropNoCommit
dropNoCommit(*hash opt)
drops the table from the database without any transaction management
SqlUtil::Table::getUpsertClosureWithValidation
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy=AbstractTable::UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
Closure
const Closure
SqlUtil::AbstractTable::setupTable
setupTable(hash desc, *hash opt)
creates the object from a table description hash
SqlUtil::Indexes::add
add(string k, AbstractIndex val)
adds the given value to the hash with the given key name
SqlUtil::Database::makeProcedure
AbstractFunction makeProcedure(string name, string src, *hash opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
SqlUtil::AbstractTable::UpsertInsertFirst
const UpsertInsertFirst
Upsert option: insert first, if the insert fails, then update.
Definition: SqlUtil.qm.dox.h:8368
SqlUtil::AbstractDatabase::getCallbackOptions
private hash getCallbackOptions()
override in subclasses to return driver-specific options
SqlUtil::Table::selectRow
*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...
SqlUtil::Table::addIndex
AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql)
adds an index to the table; if the table already exists, then it is added in the database also immedi...
SqlUtil::AbstractView::name
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:4222
SqlUtil::Table::findSingle
*hash findSingle(*hash cond)
finds a single row in the table that match the row condition passed; multiple rows may match...
SqlUtil::AbstractTrigger::constructor
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
SqlUtil::AbstractDatabase::features
list features()
See DBFeaturesConstants.
SqlUtil::AbstractSequence::max
*number max
the ending number
Definition: SqlUtil.qm.dox.h:4194
SqlUtil::AbstractTable::checkExistenceImpl
abstract private bool checkExistenceImpl()
returns True if the table exists in the DB, False if not
SqlUtil::cop_upper
hash cop_upper(any column)
returns a hash for the &quot;upper&quot; operator with the given argument; returns a column value in upper case...
SqlUtil::AbstractTable::getUpsertClosure
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 u...
SqlUtil::AbstractHashContainer::val
bool val()
Returns False if the contained hash has no keys, True if it does.
SqlUtil::Table::getAddForeignConstraintSql
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
SqlUtil::AbstractTable::selectRows
*list selectRows(*hash sh, *reference sql)
returns a list of hashes representing the rows in the table that match the argument hash ...
SqlUtil::AbstractListContainer::getList
list getList()
returns the list contained by this object
SqlUtil::AbstractTable::getRowIterator
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql)
returns an SQLStatement object that will iterate the results of a select statement matching the argum...
SqlUtil::AbstractTable::ColumnDescOptions
const ColumnDescOptions
Column description options.
Definition: SqlUtil.qm.dox.h:8298
SqlUtil::AbstractSequence::increment
number increment
the increment
Definition: SqlUtil.qm.dox.h:4191
SqlUtil::AbstractTable::getDropConstraintIfExistsSql
*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 NOT...
SqlUtil::Columns::memberGate
AbstractColumn memberGate(string k)
returns the AbstractColumn object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::AbstractHashContainer::matchKeys
bool matchKeys(hash h1)
returns True if the hash argument has the same keys (in any order), False if not
SqlUtil::AbstractDatabase::listViews
list listViews()
returns a list of string view names in the database
SqlUtil::AbstractDatabase::getDropProcedureSqlIfExists
*string getDropProcedureSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given procedure if it exists or NOTHING if the named procedure do...
SqlUtil::AbstractTable::inDb
bool inDb()
returns True if the table has been read from or created in the database, False if not ...
SqlUtil::OP_LIKE
const OP_LIKE
the SQL &quot;like&quot; operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2577
SqlUtil::Table::rollback
rollback()
rolls back the current transaction on the underlying Qore::SQL::AbstractDatasource ...
SqlUtil::AbstractDatabase::CallbackOptions
const CallbackOptions
generic callback options
Definition: SqlUtil.qm.dox.h:4939
SqlUtil::AbstractTable::TableDescriptionHashOptions
const TableDescriptionHashOptions
Table description options.
Definition: SqlUtil.qm.dox.h:8275
SqlUtil::SZ_NONE
const SZ_NONE
the data type does not take a size parameter
Definition: SqlUtil.qm.dox.h:1642
SqlUtil::Indexes::memberGate
AbstractIndex memberGate(string k)
returns the AbstractIndex object corresponding to the key given or throws a KEY-ERROR exception ...
SqlUtil::AbstractListContainer::size
int size()
Returns the number of elements in the contained list.
SqlUtil::AbstractFunction::constructor
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
SqlUtil::Tables::getDropList
list getDropList()
returns a list of cached table names in the order that can be used to drop the tables, taking into account foreign constraint dependencies
SqlUtil::Table::addTrigger
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...
SqlUtil::AbstractDatabase::ActionDescMap
const ActionDescMap
maps from action descriptions to action codes
Definition: SqlUtil.qm.dox.h:5007
SqlUtil::Table::t
AbstractTable t
the embedded AbstractTable object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:5734
SqlUtil::AbstractTable::getUpsertClosureWithValidation
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 u...
SqlUtil::AbstractTable::getSqlValueImpl
abstract private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
SqlUtil::OP_CLT
const OP_CLT
the SQL less than (&lt;) operator for use in Where Clauses when comparing two columns ...
Definition: SqlUtil.qm.dox.h:2612
SqlUtil::COP_MINUS
const COP_MINUS
the SQL &quot;minus&quot; operator
Definition: SqlUtil.qm.dox.h:1721
SqlUtil::AbstractDatabase::getProcedure
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
SqlUtil::Table::clear
clear()
purges the current table definition
SqlUtil::AbstractFunctionBase::constructor
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
SqlUtil::AbstractCheckConstraint::clearIndex
clearIndex()
clears any index base for the constraint
SqlUtil::ForeignConstraintTarget::table
string table
the name of the target table
Definition: SqlUtil.qm.dox.h:4130
hash
hash hash(object obj)
SqlUtil::AbstractTable::commit
commit()
commits the current transaction on the underlying Qore::SQL::AbstractDatasource
SqlUtil::AbstractDatabase::getNextSequenceValueImpl
abstract private int getNextSequenceValueImpl(string name)
returns the next value in the given sequence
SqlUtil::Table::commit
commit()
commits the current transaction on the underlying Qore::SQL::AbstractDatasource
SqlUtil::AbstractTable::getColumnDescOptions
private hash getColumnDescOptions()
returns the column description options for this driver
SqlUtil::AbstractTable::findUniqueConstraint
*AbstractUniqueConstraint findUniqueConstraint(string name)
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary...
SqlUtil::AbstractTable::TableCreationOptions
const TableCreationOptions
table creation options
Definition: SqlUtil.qm.dox.h:8243
SqlUtil::cop_year_day
hash cop_year_day(any column)
returns a hash for the &quot;year_day&quot; operator with the given argument
SqlUtil::AbstractDatabase::AC_Delete
const AC_Delete
used when data is deleted in a table
Definition: SqlUtil.qm.dox.h:4984
SqlUtil::Database::functionIterator
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
SqlUtil::Database::listTables
list listTables()
returns a list of string table names in the database
SqlUtil::AbstractTable::getCreateMiscSql
*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...
SqlUtil::AbstractIndex::getCreateSql
abstract string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
SqlUtil::JOP_RIGHT
const JOP_RIGHT
for right outer joins
Definition: SqlUtil.qm.dox.h:2261
SqlUtil::Table::dropTrigger
AbstractTrigger dropTrigger(string tname, *reference sql)
drops the given trigger from the table; if the table is known to be in the database already...
SqlUtil::make_uop
hash make_uop(string uop, any arg, *hash nest)
returns a hash with uop, arg, and nest keys
SqlUtil::SZ_OPT
const SZ_OPT
the data type takes an optional size parameter
Definition: SqlUtil.qm.dox.h:1648
SqlUtil::AbstractDatabase::AC_Update
const AC_Update
used when data is updated in a table
Definition: SqlUtil.qm.dox.h:4981
SqlUtil::Table::insertFromIteratorNoCommit
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
SqlUtil::Tables::getDropConstraintIfExistsSql
*string getDropConstraintIfExistsSql(string tname, string cname, *hash opts)
returns an SQL string that can be used to drop an existing constraint on a table, if the table is not...
SqlUtil::Database::makeSequence
AbstractSequence makeSequence(string name, number start=1, number increment=1, *softnumber end, *hash opts)
creates a database-specific AbstractSequence object corresponding to the arguments ...
SqlUtil::cop_year
hash cop_year(any column)
returns a hash for the &quot;year&quot; operator with the given argument
SqlUtil::AbstractSequence::start
number start
the starting number
Definition: SqlUtil.qm.dox.h:4188
SqlUtil::AbstractDatabase::AC_NotFound
const AC_NotFound
used when dropping object but the object is not present
Definition: SqlUtil.qm.dox.h:4987
SqlUtil::AbstractTable::getDropTriggerSql
list getDropTriggerSql(string tname, *hash opt)
returns SQL that can be used to drop the given trigger from the table
SqlUtil::Tables::populate
populate(AbstractDatasource ds, hash tables, *hash opt)
populates the object from a hash description
SqlUtil::AbstractDatabase
the base abstract class for the database implementation
Definition: SqlUtil.qm.dox.h:4913
SqlUtil::AbstractTable::insertFromSelectNoCommit
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 sam...
SqlUtil::AbstractTable::getTableOptions
private hash getTableOptions()
returns the table options for this driver
SqlUtil::AbstractDatabase::getDropTableSqlIfExists
*list getDropTableSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given table if it exists or NOTHING if the named table does not e...
SqlUtil::Table::upsert
int upsert(hash row, int upsert_strategy=AbstractTable::UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
SqlUtil::Table::getUniqueConstraintIterator
Qore::AbstractIterator getUniqueConstraintIterator()
returns an iterator for all unique constraints on the table (including the primary key if any) ...
SqlUtil::AbstractListContainer::take
any take(int i)
removes the given element from the contained list and returns the value
SqlUtil::cop_multiply
hash cop_multiply(any column1, any column2)
returns a hash for the &quot;*&quot; operator with the given arguments
SqlUtil::AbstractTable::select
*hash select(*hash sh, *reference sql)
returns a hash of lists representing the columns and rows in the table that match the argument hahs ...
SqlUtil::AbstractDatabase::AC_Add
const AC_Add
used when an element is added to an existing object
Definition: SqlUtil.qm.dox.h:4972
SqlUtil::Table::truncateNoCommit
truncateNoCommit()
truncates all the table data without any transaction management
SqlUtil::AbstractTable::getCreateTableSql
string getCreateTableSql(*hash opt)
returns an SQL string that could be used to create the basic table structure without indexes and cons...
SqlUtil::AbstractIndex::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the index from the database
SqlUtil::AbstractTable::getDropConstraintSql
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 ...
SqlUtil::ForeignConstraints::findEqual
*AbstractForeignConstraint findEqual(AbstractForeignConstraint fk)
find an index with columns equal to the index passed
SqlUtil::Table::getForeignConstraints
ForeignConstraints getForeignConstraints(*hash opt)
returns a ForeignConstraints object describing the foreign constraints that the table has on other ta...
SqlUtil::AbstractPrimaryKey
represents a primary key
Definition: SqlUtil.qm.dox.h:4067
SqlUtil::JOP_INNER
const JOP_INNER
for standard inner joins
Definition: SqlUtil.qm.dox.h:2251
SqlUtil::COP_LOWER
const COP_LOWER
to return column value in lower case
Definition: SqlUtil.qm.dox.h:1686
SqlUtil::AbstractDatabase::getTable
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found ...
SqlUtil::AbstractDatabase::getSequenceDescriptionOptions
private hash getSequenceDescriptionOptions()
override in subclasses to return driver-specific options
SqlUtil::AbstractTable::tryExecArgsImpl
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 ...
SqlUtil::Table::getDropColumnSql
list getDropColumnSql(string cname, *hash opt)
returns the SQL that can be used to drop a column from the table
SqlUtil::COP_DIVIDE
const COP_DIVIDE
the SQL &quot;divide&quot; operator
Definition: SqlUtil.qm.dox.h:1731
join
string join(string str,...)
SqlUtil::DB_FUNCTIONS
const DB_FUNCTIONS
Features constants.
Definition: SqlUtil.qm.dox.h:1599
SqlUtil::NUMERIC
const NUMERIC
specifies a numeric column (equivalent to Qore::Type::Number)
Definition: SqlUtil.qm.dox.h:1625
SqlUtil::AbstractFunction::getCreateSql
abstract list getCreateSql(*hash opt)
returns a list of SQL strings that can be used to create the function in the database ...
SqlUtil::AbstractConstraint::setIndexBase
abstract bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
SqlUtil::op_ceq
hash op_ceq(string arg)
returns a hash for the &quot;=&quot; operator with the given argument for use in where clauses when comparing t...
SqlUtil::Table::selectRows
*list selectRows(*hash sh, *reference sql)
returns a list of hashes representing the rows in the table that match the argument hash ...
SqlUtil::AbstractColumn::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the column from the table
SqlUtil::AbstractHashContainer::lastKey
*string lastKey()
Returns the last key name in the contained hash or NOTHING if the contained hash has no keys...
SqlUtil::Table::delNoCommit
int delNoCommit(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; no transactio...
SqlUtil::AbstractForeignConstraint::equalImpl
private bool equalImpl(AbstractConstraint con)
returns True if the argument is equal to the current object, False if not
SqlUtil::Constraints::take
AbstractConstraint take(string k)
removes the given key from the contained hash and returns the value
SqlUtil::AbstractHashContainer::firstKey
*string firstKey()
Returns the first key name in the contained hash or NOTHING if the contained hash has no keys...
Qore::AbstractIterator
SqlUtil::AbstractTable::upsertFromIterator
*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 ret...
SqlUtil::AbstractDatabase::supportsSequences
bool supportsSequences()
returns True if the database supports sequences
SqlUtil::AbstractTable::upsertFromIteratorNoCommit
*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 ret...
SqlUtil::AbstractDatabase::tryExec
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
SqlUtil::cop_year_hour
hash cop_year_hour(any column)
returns a hash for the &quot;year_hour&quot; operator with the given argument
SqlUtil::AbstractHashContainer::hasKeyValue
bool hasKeyValue(string k)
Returns True if the key exists in the contained hash and is assigned a value, False if not...
SqlUtil::AbstractTable::ConstraintOptions
const ConstraintOptions
default constraint options
Definition: SqlUtil.qm.dox.h:8184
SqlUtil::Tables::getIfExists
*AbstractTable getIfExists(AbstractDatasource ds, string name)
gets a table from the database or from the cache if already cached; if the table does not exist...
SqlUtil::DefaultOpMap
const DefaultOpMap
a hash of valid operators for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2655
SqlUtil::AbstractUniqueConstraint
represents a unique column constraint
Definition: SqlUtil.qm.dox.h:3996
SqlUtil::AbstractConstraint::rename
rename(string n)
renames the constraint
SqlUtil::AbstractTable::getUpsertOptions
private hash getUpsertOptions()
returns the upsert options for this driver
SqlUtil::AbstractDatabase::makeTable
AbstractTable makeTable(string name, hash desc, *hash opts)
creates a database-specific AbstractTable object corresponding to the arguments
SqlUtil::AbstractTable::AdditionalColumnDescOptions
const AdditionalColumnDescOptions
additional column description keys valid when describing columns in a table description hash ...
Definition: SqlUtil.qm.dox.h:8311
SqlUtil::cop_max
hash cop_max(any column)
returns a hash for the &quot;max&quot; operator; returns maximum column values
SqlUtil::AbstractConstraint
abstract base class for constraints
Definition: SqlUtil.qm.dox.h:3907
SqlUtil::Table::getSqlValue
string getSqlValue(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
SqlUtil::AbstractTable::removeForeignConstraint
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
SqlUtil::AbstractTable::upsertNoCommit
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 k...
SqlUtil::Constraints
constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:3865
SqlUtil::COP_APPEND
const COP_APPEND
to append a string to a column on output
Definition: SqlUtil.qm.dox.h:1671