393 @warning Oracle:
using different comments in the
same SQL can lead to
new optimizer statement hard parsing.
395 @subsubsection select_option_hint Select Option
"hint"
396 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).
400 table.selectRows((
"hint":
"full(t1)"));
402 will produce select statement like
this:
406 The
string is taken as-is and it
's up to the caller to handle correct aliases in join functions etc.
407 @note Hints are platform dependent. Curently only Oracle and some versions of PostgreSQL hints are supported in Sqlutil module.
408 @warning Use hints only when you know what you are doing.
410 @subsubsection select_option_columns Select Option "columns"
411 <b>Columns Example:</b>
414 "id", "name", "started",
415 cop_as("warnings", "warning_count"),
416 cop_as("errors", "error_count"),
418 *list rows = table.selectRows(("columns": columns, "where": ("type": "user")));
420 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
421 This option takes a list, each element of the list can be one of the following.\n\n
422 <b>A Simple String Giving a Column Name</b>\n
425 *list rows = table.selectRows(("columns": ("id", "name", "started")));
427 <b>A String in Dot Notation</b>\n
428 This format is for use with @ref select_option_join "joins"; ex: \c "q.name"
431 "columns": ("t1.id", "t2.customer_name"),
432 "join": join_inner(table2, "t2", ("id": "altid"))),
435 *list rows = table.selectRows(sh);
437 <b>A Column Operation Specified by a Column Operator Function</b>\n
438 ex: <tt>cop_as("column_name", "column_alias")</tt> \n
439 See @ref sql_cop_funcs "column operator function" for more information on column operator functions
443 cop_as("warnings", "warning_count"),
444 cop_as("errors", "error_count"),
446 *list rows = table.selectRows(("columns": columns));
448 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
449 <b>The Value \c "*", Meaning All Columns</b>\n
452 *list rows = table.selectRows(("columns": "*"));
454 This is the default if no \c "columns" key is included in the @ref select_option_hash "select option hash" \n\n
455 <b>An \c "*" in Dot Notation</b>\n
459 "columns": ("table.id", "t2.*"),
460 "join": join_inner(table2, "t2", ("id": "altid")),
462 *list rows = table.selectRows(sh);
465 @subsubsection select_option_where Select Option "where"
466 <b>Where Example:</b>
468 *list rows = table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
470 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.
472 @subsubsection select_option_orderby Select Option "orderby"
473 <b>Orderby Example:</b>
477 "account_type": "CUSTOMER",
479 "orderby": "created_date",
481 *list rows = table.selectRows(sh);
483 This option is a list of the following values:
484 - a simple string giving a column name; ex: \c "name"
485 - a simple string with a column name preceded by a \c "-" sign; ex: \c "-name", meaning that that column should be sorted in descending order
486 - 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"
487 - a positive integer giving the column number for the ordering
489 - By using the @ref select_option_offset "offset option" the results will be automatically ordered according to the primary key of the table
491 @subsubsection select_option_desc Select Option "desc"
496 "account_type": "CUSTOMER",
498 "orderby": "created_date",
501 *list rows = table.selectRows(sh);
503 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
504 Otherwise, ordered results are returned in ascending order by default.
506 @note per-column descending options can be given by prepending a \c "-" character to the column name in the @ref select_option_orderby "orderby option list"
508 @subsubsection select_option_limit Select Option "limit"
509 <b>Limit Example:</b>
512 "where": ("type": "user"),
516 *list rows = table.selectRows(sh);
518 This option will limit the number of rows returned.
520 - This option is required if the @ref select_option_offset "offset option" is non-zero
521 - 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
523 @subsubsection select_option_offset Select Option "offset"
524 <b>Offset Example:</b>
527 "where": ("type": "user"),
531 *list rows = table.selectRows(sh);
533 This option specifies the row number offset for the rows returned where the first row is at offset zero.
535 - 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.
536 - Additionally, this option requires the presence of the @ref select_option_limit "limit option", or an exception will be thrown.
539 @subsubsection select_option_join Select Option "join"
544 "name", "version", "id",
545 cop_as("st.value", "source"),
546 cop_as("st.value", "offset"),
548 "join": join_left(function_instance_tags, "st", NOTHING, ("st.tag": "_source"))
549 + join_left(function_instance_tags, "lt", NOTHING, ("st.tag": "_offset")),
551 *list rows = table.selectRows(sh);
553 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).
554 @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
556 @see @ref joins for more examples
558 @subsubsection select_option_groupby Select Option "groupby"
559 <b>Groupby Example:</b>
563 cop_as(cop_max("service_type"), "type"),
566 "groupby": "service_type",
568 *list rows = table.selectRows(sh);
570 The \c "groupby" option allows for aggregate SQL column operator functions to be used (ex: @ref cop_max(), cop_min()) in select statements.
571 The \c "groupby" hash key should be assigned to a list of column specifiers or a single column specifier. Column specifiers for the \c "groupby"
572 key are strings giving column names, optionally in dot notation or positive column numbers.
574 @subsubsection select_option_having Select Option "having"
575 <b>Having Example:</b>
579 cop_as(cop_max("service_type"), "type"),
582 "groupby": "service_type",
584 "service_type": (COP_COUNT, op_ge(100)),
587 *list rows = table.selectRows(sh);
589 The \c "having" option allows for query results with aggregate SQL column operator functions to be filtered by user-defined criteria.
590 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.
592 @subsubsection select_option_superquery Select Option "superquery"
593 <b>Superquery Example:</b>
597 "serviceid", "service_methodid",
598 cop_as(cop_over(cop_max("service_methodid"), "serviceid"), "max_methodid"),
601 "columns": ("serviceid", "service_methodid"),
602 "where": ("max_methodid": op_ceq("service_methodid")),
605 *list rows = table.selectRows(sh);
607 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
608 The above example results in an SQL command equivalent to the following:
610 *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");
612 @note that MySQL does not support SQL windowing functions so the above example would fail on MySQL.
614 @subsubsection select_option_forupdate Select Option "forupdate"
615 <b>For Update Example:</b>
617 on_success ds.commit();
618 on_error ds.rollback();
621 "columns": ("serviceid", "service_methodid"),
624 *list rows = table.selectRows(sh);
626 \n The \c "forupdate" option allows for the rows selected to be locked for updating; to release the locks, call commit() or rollback() on the underlying datasource object.
627 The above example results in an SQL commit equivalent to the following:
629 *list rows = table.vselectRows("select serviceid,service_methodid from schema.service_methods for update");
632 @subsection sql_paging Select With Paging
634 There is support for paging query results in the following methods:
635 - @ref SqlUtil::AbstractTable::getRowIterator()
636 - @ref SqlUtil::AbstractTable::getSelectSql()
637 - @ref SqlUtil::AbstractTable::select()
638 - @ref SqlUtil::AbstractTable::selectRows()
640 @note the above list also applies to the corresponding @ref SqlUtil::AbstractTable methods
642 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.
644 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.
647 Select 100 rows starting at row 200 (the table's primary key will be used
for the \c
"orderby" option by
default): \n
649 *
list rows = table.selectRows((
"where": (
"type":
"user"),
"limit": 100,
"offset": 200));
651 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:
653 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));
657 ds.vselectRows(
"select * from public.table where type = %v order by type limit %v offset %v", (
"user", 100, 200));
660 @subsection check_matching_rows Check For At Least One Matching Row
664 *
hash h = table.findSingle((
"account_type":
"CUSTOMER"));
666 printf(
"found 1 customer row: %y\n", l[0]);
669 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):
671 *hash h = table.selectRow(("where": ("account_type": "CUSTOMER"), "limit": 1));
673 printf("found 1 customer row: %y\n", l[0]);
676 @section inserting_data Inserting Data into the Database
678 The following methods can be used to insert data into the database:
679 - @ref SqlUtil::AbstractTable::insert(): inserts a single row into a table without committing the transaction
680 - @ref SqlUtil::AbstractTable::insertCommit(): inserts a single row into a table and commits the transaction
681 - @ref SqlUtil::AbstractTable::insertFromSelect(): 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
682 - @ref SqlUtil::AbstractTable::insertFromSelectCommit(): 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
684 @see @ref sql_upsert for information about upserting or merging data
686 @subsection inserting_data_explicitly Inserting Data Explicitly
690 table.insert(("id": id, "name": name, "created": now_us()));
693 Data can be explicitly inserted into the database with immediate values with @ref SqlUtil::AbstractTable::insert() and @ref SqlUtil::AbstractTable::insertCommit() as in the above example.
695 Additionally, instead of giving a literal value to be inserted, @ref sql_iop_funcs can be used to insert values based on SQL operations used directly in the insert statement.
697 @subsection inserting_data_from_select Inserting Data From a Select Statement
701 int rows = table.insertFromSelect(("id", "name", "created"), source_table, (("columns": ("cid", "fullname", "created"), "where": ("type": "CUSTOMER"))));
704 Data can be inserted into the database based on the results of a select statement with @ref SqlUtil::AbstractTable::insertFromSelect() and @ref SqlUtil::AbstractTable::insertFromSelectCommit() as in the above example.
706 The example above would generate a %Qore SQL command like the following:
708 return ds.vexec("insert into schema.table (id,name,created) select cid,fullname,created from schema.source_table where type = %v", ("CUSTOMER"));
711 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.
713 @subsection inserting_data_from_iterator Inserting Data from an Iterator Source
715 To insert data from an iterator source (such as an @ref Qore::SQL::SQLStatement object), call @ref SqlUtil::AbstractTable::insertFromIterator() or @ref SqlUtil::AbstractTable::insertFromIteratorCommit() as in the following example:
719 # get the rows to be inserted
720 list l = get_table_rows();
721 # insert the data and commit after every 5000 rows
722 table.insertFromIterator(l.iterator(), ("commit_block": 5000));
725 The iterator given to the @ref SqlUtil::AbstractTable::insertFromIterator() or @ref SqlUtil::AbstractTable::insertFromIteratorCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "hash".
727 @note the @ref SqlUtil::AbstractTable::InsertFromIteratorOptions "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
729 @section updating_data Updating Data
731 The following methods can be used to update data:
733 - @ref SqlUtil::AbstractTable::updateCommit(): updates a single row and commits the transaction
740 The example above generates a %Qore SQL command like the following on Oracle and PostgreSQL
for example:
742 return ds.vexec(
"update schema.table set permission_type = lower(permission_type) || '-migrated');
744 And the following on MySQL:
746 return ds.vexec("update schema.table set permission_type = concat(lower(permission_type),
'-migrated'));
749 @section deleting_data Deleting Data
751 The following methods can be used to dekete data:
752 - @ref
SqlUtil::AbstractTable::del(): updates the table based on a @ref where_clauses
"where clause" and does not commit the transaction
753 - @ref SqlUtil::AbstractTable::delCommit(): updates the table based on a @ref where_clauses
"where clause" and commits the transaction
754 - @ref SqlUtil::AbstractTable::truncate(): truncates the table and does not commit the transaction
755 - @ref SqlUtil::AbstractTable::truncateCommit(): truncates the table and commits the transaction releasing the transaction lock on the underlying datasource object
759 int dcnt = table.del((
"record_type":
"OLD-CUSTOMER"));
762 The above example would generate a %Qore SQL command like the following:
764 return ds.vexec(
"delete from schema.table where record_type = %v", (
"OLD-CUSTOMER"));
767 The @ref
SqlUtil::AbstractTable::del() and @ref SqlUtil::AbstractTable::delCommit() methods can be used to delete data from the database.
769 See @ref where_clauses for information about specifying the criteria for the rows to be deleted.
771 @section joins Joining Tables
773 Joining tables is made by providing a
join specification to the @ref select_option_join "
join select option" in
774 a @ref select_option_hash "select option
hash" as in the following example:
776 *
list rows = table.selectRows((
"columns": (
"table.id",
"t2.customer_name"),
"join":
join_inner(table2,
"t2", (
"id":
"altid"))));
778 In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt>.
780 Joins on multiple tables are performed by combining the results of @ref sql_jop_funcs
"join functions" with the @ref plus_operator
"+ operator"
785 In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt> and with \a table3 on an
786 automatically detected primary key to foreign key relationship between the two tables.
788 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
789 argument to the @ref sql_jop_funcs
"join function" as in the following example:
791 *
list rows = table.selectRows((
"join":
join_inner(table2,
"t2", (
"id":
"altid")) +
join_inner(
"t2", table3,
"t3")));
793 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
794 with \a table3 (aliased as \c t3) on an automatically detected primary key to foreign key relationship between the two tables.
796 @see @ref select_option_join
"join select option"
798 @section where_clauses Where Clauses
800 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:
819 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", there are two options:
820 - use the @ref
SqlUtil::wop_or() function to combine where expressions with the \c "or" operator
821 - 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".
823 The where condition
hash has the following format:
824 - each key gives a column name or a table/alias with column name in dot notation
825 - 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
827 @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{.py}
hash w = (
"0:created":
op_ge(mindate),
"1:created":
op_lt(maxdate));
@endcode
829 See @ref sql_op_funcs
for a
list of
operator functions.
831 @par Where
Hash Example:
835 "account_type":
op_like(
"%CUSTOMER%"),
839 The preceding example results in a where clause equivalent to: \c
"name = 'Smith' and type like '%CUSTOMER%' and id >= 500", except
840 that bind by value is used, so,
if used in a context like the following:
842 Table t(ds,
"table");
843 *
hash qh = t.select((
"where": w));
845 the complete query would look instead as follows:
847 ds.vselect(
"select * from table where name = %v and account_type like %v and id >= %v", (
"Smith",
"%CUSTOMER%", 500));
851 @par Where
List Example:
855 "account_type":
op_like(
"%CUSTOMER%"),
860 "account_type":
op_like(
"%VENDOR%"),
863 Table t(ds,
"table");
864 *
hash qh = t.select((
"where": (w1, w2)));
866 the complete query would look instead as follows:
868 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));
872 Find a single row in the table where the \c
"permission_type" column is a value between \c
"US" and \c
"UX":\n
874 *
hash row = table.findSingle((
"permission_type":
op_between(
"US",
"UX")));
876 resulting in an
internal SQL command that looks as follows (depending on the database):
878 *
hash row = ds.vselectRow(
"select * from table where permission_type between %v and %v limit %v", (
"US",
"UX", 1));
880 Delete all rows in the table where the \c
"name" column is like \c
"%Smith%":\n
882 int row_count = table.del((
"name":
op_like(
"%Smith%")));
884 resulting in an
internal SQL command that looks as follows:
886 ds.vexec(
"delete from table where name like %v", (
"%Smith%"));
888 Find all rows where \c
"id" is greater than \c 100 and \c
"created" is after \c 2013-03-01:\n
890 *
list rows = table.findAll((
"id":
op_gt(100),
"created":
op_gt(2013-03-01)));
892 resulting in an
internal SQL command that looks as follows:
894 ds.vexec(
"select * from table where id > %v and created > %v", (100, 2013-03-01));
897 @section sql_upsert Upserting or Merging Data
899 This module offers a high-level api
for "upserting" or merging data from one table into another table through the following methods:
909 @subsection sql_upsert_single Upsert a Single Row
913 table.upsert((
"id":
id,
"name": name,
"account_type": account_type));
916 To upsert or merge a single row in the database, call @ref
SqlUtil::AbstractTable::upsert() or @ref SqlUtil::AbstractTable::upsertCommit() with the
917 single row to be upserted or merged as a
hash as in the preceding example.
919 @subsection sql_upsert_many Upserting Many Rows Using An Upsert
Closure
921 To upsert or merge many rows by using an upsert closure, call @ref SqlUtil::AbstractTable::getUpsertClosure() or @ref SqlUtil::AbstractTable::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.
925 # get the rows to be inserted
926 list l = get_table_rows();
929 code upsert = table.getUpsertClosure(l[0]);
931 on_success ds.commit();
932 on_error ds.rollback();
934 # loop through the reference data rows
939 @par Complex Example With Callbacks:
941 # set the upsert strategy depending on the use case
944 # hash summarizing changes
947 # get the rows to be inserted
948 list l = get_table_rows();
951 # get the upsert closure to use based on the first row to be inserted
952 code upsert = table.getUpsertClosure(l[0], upsert_strategy);
954 on_success ds.commit();
955 on_error ds.rollback();
957 # loop through the reference data rows
958 foreach hash h in (l) {
959 int code = upsert(h);
970 else if (verbose > 1)
971 printf(
"*** reference data %s: %y: %s\n", table.getName(), h, change);
976 printf(
"*** reference data %s: %s\n", table.getName(), (foldl $1 +
", " + $2, (map
sprintf(
"%s: %d", $1.key, $1.value), sh.pairIterator())));
978 printf(
"*** reference data %s: OK\n", table.getName());
982 @subsection sql_upsert_from_iterator Upserting Many Rows from an Iterator Source
988 # get the rows to be inserted
989 list l = get_table_rows();
990 table.upsertFromIterator(l.iterator());
993 @par Complex Example With Callbacks:
995 # set the upsert strategy depending on the use case
998 # get the rows to be inserted
999 list l = get_table_rows();
1001 code callback = sub (
string table_name,
hash row,
int result) {
1006 printf(
"*** reference data %s: %y: %s\n", table_name, row, change);
1009 hash sh = table.upsertFromIterator(l.iterator(), upsert_strategy,
False, (
"info_callback": callback,
"commit_block": 5000));
1011 printf(
"*** reference data %s: %s\n", table.getName(), (foldl $1 +
", " + $2, (map
sprintf(
"%s: %d", $1.key, $1.value), sh.pairIterator())));
1013 printf(
"*** reference data %s: OK\n", table.getName());
1016 The iterator given to the @ref
SqlUtil::AbstractTable::upsertFromIterator() or @ref SqlUtil::AbstractTable::upsertFromIteratorCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "
hash".
1018 @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
1020 @subsection sql_upsert_from_select Upserting Many Rows from a Select Statement
1022 To upsert or merge many rows from a select statement, use @ref SqlUtil::AbstractTable::upsertFromSelect() or @ref SqlUtil::AbstractTable::upsertFromSelectCommit() as in the following example:
1024 @par Simple Example:
1026 table.upsertFromSelect(table2, (
"where": (
"account_type":
"CUSTOMER")));
1029 @par Complex Example With Callbacks:
1031 # set the upsert strategy depending on the use case
1034 code callback = sub (
string table_name,
hash row,
int result) {
1039 printf(
"*** reference data %s: %y: %s\n", table_name, row, change);
1042 hash sh = table.upsertFromSelect(table2, (
"where": (
"account_type":
"CUSTOMER")), upsert_strategy, False, (
"info_callback": callback,
"commit_block": 5000));
1044 printf(
"*** reference data %s: %s\n", table.getName(), (foldl $1 +
", " + $2, (map
sprintf(
"%s: %d", $1.key, $1.value), sh.pairIterator())));
1046 printf(
"*** reference data %s: OK\n", table.getName());
1049 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).
1051 @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
1053 @subsection sql_upsert_with_delete Upserting Many Rows and Deleting Unwanted Rows
1055 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.
1057 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.
1059 @par Simple Example:
1061 # get the rows to be inserted
1062 list l = get_table_rows();
1063 table.upsertFromSelect(table2, ("where": ("account_type": "CUSTOMER")), AbstractTable::UpsertAuto, ("delete_others": True, "commit_block": 5000));
1066 @par Complex Example With Callbacks:
1068 # set the upsert strategy depending on the use case
1069 int upsert_strategy = verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
1071 # get the rows to be inserted
1072 list l = get_table_rows();
1074 code callback = sub (string table_name, hash row, int result) {
1075 if (result == AbstractTable::UR_Unchanged)
1077 string change = AbstractTable::UpsertResultMap{result};
1079 printf("*** reference data %s: %y: %s\n", table_name, row, change);
1082 hash sh = table.upsertFromSelect(table2, ("where": ("account_type": "CUSTOMER")), upsert_strategy, ("delete_others": True, "info_callback": callback, "commit_block": 5000));
1084 printf("*** reference data %s: %s\n", table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), sh.pairIterator())));
1086 printf("*** reference data %s: OK\n", table.getName());
1089 @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
1091 @subsection sql_upsert_strategies Upsert Strategies
1092 The approach used is based on one of the following strategies (see @ref upsert_options):
1093 - @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; note that
if a driver-specific optimized version of the upsert operation is implemented,
this strategy will normally result in the best performance
1094 - @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
1095 - @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
1097 - @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
1098 - @ref SqlUtil::AbstractTable::UpsertUpdateOnly "AbstractTable::UpsertUpdateOnly": update if the row exists, otherwise do nothing and @ref upsert_results "upsert result" @ref SqlUtil::AbstractTable::UR_Unchanged is returned
1100 @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.
2434 "code":
string (
string cve,
string arg, reference psch) {
2437 psch{arg.substr(1, -1)} = cve;
2440 return sprintf(
"%s as %s", cve, arg);
2446 "code":
string (
string cve,
string arg) {
2447 return sprintf(
"%s || %s", arg, cve);
2453 "code":
string (
string cve,
string arg) {
2454 return sprintf(
"%s || %s", cve, arg);
2460 "code":
string (*
string cve,
auto arg) {
2465 "code":
string (
string cve,
auto arg) {
2466 return sprintf(
"upper(%s)", cve);
2470 "code":
string (
string cve,
auto arg) {
2471 return sprintf(
"lower(%s)", cve);
2475 "code":
string (
string cve,
auto arg) {
2476 return sprintf(
"distinct %s", cve);
2480 "code":
string (
string cve,
auto arg) {
2481 return sprintf(
"min(%s)", cve);
2486 "code":
string (
string cve,
auto arg) {
2487 return sprintf(
"max(%s)", cve);
2492 "code":
string (
string cve,
auto arg) {
2493 return sprintf(
"avg(%s)", cve);
2498 "code":
string (
string cve,
auto arg) {
2499 return sprintf(
"sum(%s)", cve);
2505 "code":
string (*
string cve,
auto arg) {
2506 return sprintf(
"count(%s)", cve ? cve :
"*");
2511 "code":
string (
string arg1,
string arg2) {
2512 return sprintf(
"%s - %s", arg1, arg2);
2517 "code":
string (
string arg1,
string arg2) {
2518 return sprintf(
"%s + %s", arg1, arg2);
2523 "code":
string (
string arg1,
string arg2) {
2524 return sprintf(
"%s / %s", arg1, arg2);
2529 "code":
string (
string arg1,
string arg2) {
2530 return sprintf(
"%s * %s", arg1, arg2);
2535 "code":
string (*
string cve,
hash arg) {
2536 throw "SEQUENCE-ERROR",
sprintf(
"cannot select sequence %y because this database does not support sequences", arg.seq);
2541 "code":
string (*
string cve,
hash arg) {
2542 throw "SEQUENCE-ERROR",
sprintf(
"cannot select the current value of sequence %y because this database does not support sequences", arg.seq);
2547 "code":
string (*
string cve,
hash arg) {
2548 return sprintf(
"coalesce(%s)", (foldl $1 +
"," + $2, arg.args));
2552 "code":
string (
string cve,
list args) {
2554 return sprintf(
"substring(%s from %d)", cve, args[0]);
2555 return sprintf(
"substring(%s from %d for %d)", cve, args[0], args[1]);
2559 "code":
string (
string cve,
auto arg) {
2560 return sprintf(
"length(%s)", cve);
2564 "columnargs" :
True,
2565 "columnargs_ignore_nothings" :
True,
2566 "code":
string (*
string cve,
hash args)
2568 *
string partitionby = args.args[0];
2569 *
string orderby = args.args[1];
2572 string sql = cve +
" over (";
2574 sql +=
sprintf(
"partition by %s", partitionby);
2576 sql +=
sprintf(
" order by %s", orderby);
2583 "code":
string (*
string cve, any arg) {
2584 return "cume_dist()";
2589 "code":
string (*
string cve, any arg) {
2590 return "dense_rank()";
2594 "code":
string (
string cve) {
2595 return sprintf(
"first_value(%s)", cve);
2599 "code":
string (
string cve) {
2600 return sprintf(
"last_value(%s)", cve);
2606 "code":
string (*
string cve, any arg) {
2607 return sprintf(
"ntile(%d)", arg);
2612 "code":
string (*
string cve, any arg) {
2613 return "percent_rank()";
2618 "code":
string (*
string cve, any arg) {
2624 "code":
string (*
string cve, any arg) {
2625 return "row_number()";
2681 hash<ColumnOperatorInfo>
make_cop(
string cop,
auto column,
auto arg);
2697 hash<ColumnOperatorInfo>
cop_as(
auto column,
string arg);
2715 hash<ColumnOperatorInfo>
cop_cast(
auto column,
string arg,
auto arg1,
auto arg2);
2729 hash<ColumnOperatorInfo>
cop_prepend(
auto column,
string arg);
2743 hash<ColumnOperatorInfo>
cop_append(
auto column,
string arg);
2875 hash<ColumnOperatorInfo>
cop_value(
auto arg);
2888 hash<ColumnOperatorInfo>
cop_upper(
auto column);
2901 hash<ColumnOperatorInfo>
cop_lower(
auto column);
2927 hash<ColumnOperatorInfo>
cop_min(
auto column);
2940 hash<ColumnOperatorInfo>
cop_max(
auto column);
2953 hash<ColumnOperatorInfo>
cop_avg(
auto column);
2966 hash<ColumnOperatorInfo>
cop_sum(
auto column);
2977 hash<ColumnOperatorInfo>
cop_count(
auto column =
"");
2988 hash<ColumnOperatorInfo>
cop_over(
auto column, *
string partitionby, *
string orderby);
3002 hash<ColumnOperatorInfo>
cop_minus(
auto column1,
auto column2);
3016 hash<ColumnOperatorInfo>
cop_plus(
auto column1,
auto column2);
3030 hash<ColumnOperatorInfo>
cop_divide(
auto column1,
auto column2);
3044 hash<ColumnOperatorInfo>
cop_multiply(
auto column1,
auto column2);
3057 hash<ColumnOperatorInfo>
cop_year(
auto column);
3110 hash<ColumnOperatorInfo>
cop_seq(
string seq, *
string as);
3140 hash<ColumnOperatorInfo>
cop_coalesce(
auto col1,
auto col2);
3155 hash<ColumnOperatorInfo>
cop_substr(
auto column,
int start, *
int count);
3170 hash<ColumnOperatorInfo>
cop_length(
auto column);
3188 hash<ColumnOperatorInfo>
cop_trunc_date(
auto column,
string mask);
3351 hash<ColumnOperatorInfo>
cop_ntile(
int value);
3415 hash<ColumnOperatorInfo>
cop_rank();
3536 "code":
string (
string cve,
auto arg) {
3537 return sprintf(
"%s - %s", cve, arg);
3542 "code":
string (
string cve,
auto arg) {
3543 return sprintf(
"%s + %s", cve, arg);
3548 "code":
string (
string cve,
auto arg) {
3549 return sprintf(
"%s / %s", cve, arg);
3554 "code":
string (
string cve,
auto arg) {
3555 return sprintf(
"%s * %s", cve, arg);
3561 "code":
string (*
string cve,
string arg) {
3562 throw "SEQUENCE-ERROR",
sprintf(
"cannot select sequence %y because this database does not support sequences", arg);
3567 "code":
string (*
string cve,
string arg) {
3568 throw "SEQUENCE-ERROR",
sprintf(
"cannot select the current value of sequence %y because this database does not support sequences", arg);
3573 "code":
string (*
string cve, softlist args) {
3574 return sprintf(
"coalesce(%s)", (foldl $1 +
"," + $2, args));
3610 hash<UpdateOperatorInfo>
make_uop(
string uop,
auto arg, *hash<UpdateOperatorInfo> nest);
3624 hash<UpdateOperatorInfo>
uop_prepend(
string arg, *hash<UpdateOperatorInfo> nest);
3638 hash<UpdateOperatorInfo>
uop_append(
string arg, *hash<UpdateOperatorInfo> nest);
3651 hash<UpdateOperatorInfo>
uop_upper(*hash<UpdateOperatorInfo> nest);
3664 hash<UpdateOperatorInfo>
uop_lower(*hash<UpdateOperatorInfo> nest);
3679 hash<UpdateOperatorInfo>
uop_substr(
int start, *
int count, *hash<UpdateOperatorInfo> nest);
3693 hash<UpdateOperatorInfo>
uop_plus(
auto arg, *hash<UpdateOperatorInfo> nest);
3707 hash<UpdateOperatorInfo>
uop_minus(
auto arg, *hash<UpdateOperatorInfo> nest);
3721 hash<UpdateOperatorInfo>
uop_multiply(
auto arg, *hash<UpdateOperatorInfo> nest);
3735 hash<UpdateOperatorInfo>
uop_divide(
auto arg, *hash<UpdateOperatorInfo> nest);
3748 hash<UpdateOperatorInfo>
uop_seq(
string seq);
3815 hash<string, hash<JoinOperatorInfo>>
make_jop(
string jop,
string table_name, *
string alias, *
hash jcols, *
hash cond, *
string ta, *
hash opt);
3884 hash<string, hash<JoinOperatorInfo>>
join_inner(
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
3960 hash<string, hash<JoinOperatorInfo>>
join_inner_alias(
string ta,
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
4031 hash<string, hash<JoinOperatorInfo>>
join_left(
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
4105 hash<string, hash<JoinOperatorInfo>>
join_left_alias(
string ta,
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
4176 hash<string, hash<JoinOperatorInfo>>
join_right(
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
4250 hash<string, hash<JoinOperatorInfo>>
join_right_alias(
string ta,
string table_name, *
string alias, *
hash jcols, *
hash cond, *
hash opt);
4349 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4351 return sprintf(
"%s like %v", cn);
4355 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4357 return sprintf(
"%s < %v", cn);
4361 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4363 return sprintf(
"%s <= %v", cn);
4367 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4369 return sprintf(
"%s > %v", cn);
4373 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4375 return sprintf(
"%s >= %v", cn);
4379 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4381 return sprintf(
"%s is not null", cn);
4383 return sprintf(
"(%s != %v or %s is null)", cn, cn);
4387 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4389 return sprintf(
"%s is null", cn);
4391 return sprintf(
"%s = %v", cn);
4395 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4398 return sprintf(
"%s between %v and %v", cn);
4402 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4403 *
string ins = (foldl $1 +
"," + $2, (map t.getSqlValue($1), arg));
4404 return exists ins ?
sprintf(
"%s in (%s)", cn, ins) :
"1 != 1";
4409 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4410 return sprintf(
"not (%s)", cn);
4415 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4416 return sprintf(
"%s < %s", cn, arg);
4421 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4422 return sprintf(
"%s <= %s", cn, arg);
4427 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4428 return sprintf(
"%s > %s", cn, arg);
4433 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4434 return sprintf(
"%s >= %s", cn, arg);
4439 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4440 return sprintf(
"%s != %s", cn, arg);
4445 "code":
string (
object t,
string cn,
string arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4446 return sprintf(
"%s = %s", cn, arg);
4450 "code":
string (
object t,
string cn,
auto arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4456 return sprintf(
"substring(%s from %v for %v) = %v", cn);
4460 "code":
string (
object t,
string cn,
list arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch) {
4461 return t.getOrClause(arg, \args, jch,
join, ch, psch);
4489 hash<OperatorInfo>
make_op(
string op,
auto arg);
4503 hash<OperatorInfo>
op_like(
string str);
4518 hash<OperatorInfo>
op_lt(
auto arg);
4533 hash<OperatorInfo>
op_le(
auto arg);
4548 hash<OperatorInfo>
op_gt(
auto arg);
4563 hash<OperatorInfo>
op_ge(
auto arg);
4580 hash<OperatorInfo>
op_ne(
auto arg);
4597 hash<OperatorInfo>
op_eq(
auto arg);
4613 hash<OperatorInfo>
op_between(
auto l,
auto r);
4626 hash<OperatorInfo>
op_in();
4667 hash<OperatorInfo>
op_clt(
string arg);
4682 hash<OperatorInfo>
op_cle(
string arg);
4697 hash<OperatorInfo>
op_cgt(
string arg);
4712 hash<OperatorInfo>
op_cge(
string arg);
4727 hash<OperatorInfo>
op_cne(
string arg);
4742 hash<OperatorInfo>
op_ceq(
string arg);
4757 hash<OperatorInfo>
op_substr(
int start, *
int count,
string text);
4771 hash<OperatorInfo>
op_substr(
int start,
string text);
4829 hash<InsertOperatorInfo>
make_iop(
string iop,
auto arg);
4842 hash<InsertOperatorInfo>
iop_seq(
string arg);
4882 constructor(*
hash nh);
4909 auto memberGate(
string k);
4923 abstract auto take(
string k);
4926 renameKey(
string old_name,
string new_name);
4943 bool matchKeys(
hash h1);
4956 bool matchKeys(
list l);
4982 bool partialMatchKeys(
hash h1);
4995 bool partialMatchKeys(
list l);
5032 list<string> keys();
5104 bool hasKey(
string k);
5117 bool hasKeyValue(
string k);
5147 abstract string getElementName();
5164 constructor(softlist nl);
5179 abstract auto get(softint i);
5233 abstract string getElementName();
5251 constructor(AbstractDatasource ds,
hash tables, *
hash opt);
5255 constructor(AbstractDatasource ds);
5259 add(
string k,
Table val);
5279 populate(AbstractDatasource ds,
hash tables, *
hash opt);
5283 populate(AbstractDatasource ds);
5301 *
list getDropAllForeignConstraintsOnTableSql(
string name, *
hash opt);
5324 string getElementName();
5328 *
AbstractTable getIfExists(AbstractDatasource ds,
string name);
5351 *
string getRenameTableIfExistsSql(
string old_name,
string new_name, *
hash opts);
5366 bool tableRenamed(
string old_name,
string new_name,
string old_sql_name);
5371 tableRenamedIntern(
string old_name,
string new_name,
string oldsn);
5391 *
string getDropConstraintIfExistsSql(
string tname,
string cname, *
hash opts);
5394 list getCreateList();
5425 getDependencies(reference<hash> tdh, reference<hash> sdh, *reference<hash> th);
5435 constructor(*
hash c) ;
5474 string getElementName();
5510 constructor(
string n,
string nt, *
string qt,
int sz,
bool nul, *
string dv, *
string c);
5514 string getNativeTypeString();
5534 string getDropSql(
string table_name);
5565 abstract string getRenameSql(
AbstractTable t,
string new_name);
5607 constructor(softint n_scale = 0);
5611 string getNativeTypeString(
string native_type,
int precision);
5619 constructor(*
hash c) ;
5657 string getElementName();
5684 constructor(
string n,
bool u,
hash c);
5692 bool hasColumn(
string cname);
5696 abstract string getCreateSql(
string table_name, *
hash opt);
5699 string getDropSql(
string table_name);
5714 abstract string getRenameSql(
string table_name,
string new_name);
5721 setSupportingConstraint();
5729 list getRecreateSql(AbstractDatasource ds,
string table_name, *
hash opt);
5737 constructor(*
hash c) ;
5771 string getElementName();
5790 constructor(
string n);
5802 abstract string getCreateSql(
string table_name, *
hash opt);
5805 string getDropSql(
string table_name);
5809 abstract list getRenameSql(
string table_name,
string new_name);
5812 string getDisableSql(
string table_name);
5816 string getEnableSql(
string table_name, *
hash opt);
5830 abstract bool setIndexBase(
string ix);
5833 abstract clearIndex();
5836 bool hasColumn(
string cname);
5851 constructor(
string n,
string n_src) ;
5862 bool setIndexBase(
string ix);
5884 constructor(
string n, *
hash c, *
string n_index) ;
5888 constructor(
string n,
Columns c, *
string n_index) ;
5900 hash getDisableReenableSql(AbstractDatasource ds,
string table_name, *
hash opts);
5904 findMatchingIndex(*
Indexes indexes);
5922 removeSourceConstraint(
string tname,
list cols);
5926 renameSourceConstraintTable(
string old_name,
string new_name);
5930 bool hasColumn(
string cname);
5945 bool setIndexBase(
string ix);
5953 abstract string getCreateSql(
string table_name, *
hash opts);
5961 constructor(
string n, *
hash c, *
string n_index) ;
5972 constructor(
string n, *
hash c) ;
5980 constructor(*
hash c) ;
6015 *
hash findConstraintOn(
string table, softlist cols);
6019 string getElementName();
6037 constructor(
string t,
Columns c);
6086 constructor(
string n_name,
number n_start = 1,
number n_increment = 1, *softnumber n_max);
6090 abstract string getCreateSql(*
hash opt);
6095 string getDropSql(*
hash opt);
6102 abstract softlist getRenameSql(
string new_name, *
hash opt);
6125 constructor(
string n_name,
string n_src);
6129 abstract string getCreateSql(*
hash opt);
6134 string getDropSql(*
hash opt);
6141 abstract softlist getRenameSql(
string new_name, *
hash opt);
6165 constructor(
string n,
string n_type,
string n_src);
6175 string getDropSql(*
hash opt);
6198 constructor(
string n,
string n_type,
string n_src) ;
6202 abstract list getCreateSql(*
hash opt);
6208 abstract softlist getRenameSql(
string new_name, *
hash opt);
6211 setName(
string new_name);
6219 constructor(*
hash c) ;
6249 string getElementName();
6258 constructor(
string n,
string n_src) ;
6262 abstract list getCreateSql(
string table_name, *
hash opt);
6265 abstract softlist getRenameSql(
string table_name,
string new_name);
6268 abstract list getDropSql(
string table_name);
6275 constructor(*
hash c) ;
6305 string getElementName();
6341 constructor(AbstractDatasource ds, *
hash opts);
6355 constructor(
string ds, *
hash opts);
6385 any methodGate(
string meth);
6413 constructor(AbstractDatasource nds, *
hash nopts);
6417 static string makeDatasourceDesc(AbstractDatasource ds);
6421 validateOptionsIntern(
string err,
hash ropt, reference<hash> opt,
string tag);
6427 static validateOptionIntern(
string err,
string type, reference opt,
string k,
string tag);
6434 validateHashKeysForWhitespaces(
auto node);
6443 string getDriverName();
6447 string getDatasourceDesc();
6460 const DatabaseOptions = (
6468 const CacheOptions = (
6469 "table_cache":
"Tables",
6478 const CallbackOptions = (
6479 "info_callback":
"code",
6480 "sql_callback":
"code",
6492 const AC_Unchanged = 0;
6496 const AC_Create = 1;
6502 const AC_Rename = 3;
6505 const AC_Modify = 4;
6508 const AC_Truncate = 5;
6514 const AC_Recreate = 7;
6517 const AC_Insert = 8;
6520 const AC_Update = 9;
6523 const AC_Delete = 10;
6526 const AC_NotFound = 11;
6531 AC_Unchanged:
"unchanged",
6532 AC_Create:
"create",
6534 AC_Rename:
"rename",
6535 AC_Modify:
"modify",
6536 AC_Truncate:
"truncate",
6538 AC_Recreate:
"recreate",
6539 AC_Insert:
"insert",
6540 AC_Update:
"update",
6541 AC_Delete:
"delete",
6542 AC_NotFound:
"not found",
6546 const ActionDescMap = (
6547 "unchanged": AC_Unchanged,
6548 "create": AC_Create,
6550 "rename": AC_Rename,
6551 "modify": AC_Modify,
6552 "truncate": AC_Truncate,
6554 "recreate": AC_Recreate,
6555 "insert": AC_Insert,
6556 "update": AC_Update,
6557 "delete": AC_Delete,
6558 "not found": AC_NotFound,
6562 const ActionLetterMap = (
6584 const CreationOptions = CallbackOptions + (
6586 "table_cache":
"Tables",
6595 const AlignSchemaOptions = CreationOptions + (
6603 const DropSchemaOptions = CallbackOptions + (
6620 const SchemaDescriptionOptions = (
6643 const SequenceDescriptionOptions = (
6650 const ComputeStatisticsOptions = (
6651 "tables" :
"softstringlist",
6655 const ReclaimSpaceOptions = (
6656 "tables" :
"softstringlist",
6675 constructor(AbstractDatasource nds, *
hash nopts) ;
6683 static doOkCallback(*
hash opt,
int ac,
string type,
string name, *
string table, *
string info);
6687 static runInfoCallback(code info_callback,
int ac,
string type,
string name, *
string table, *
string new_name, *
string info);
6691 static *
string doCallback(*
hash opt, *
string sql,
int ac,
string type,
string name, *
string table, *
string new_name, *
string info);
6693 static list doCallback(*
hash opt,
list sql,
int ac,
string type,
string name, *
string table, *
string new_name, *
string info);
6707 any tryExec(
string sql);
6721 any tryExecArgs(
string sql, *softlist args);
6736 any tryExecRaw(
string sql);
6776 list dropSqlUnlocked(
string type,
hash schema_hash, code
get, code make, *
hash opt,
string make_arg_type);
6782 list alignCodeUnlocked(
string type,
hash schema_hash, code
get, code make, *
hash opt,
string make_arg_type);
6867 bool dropFunctionIfExists(
string name, *
hash opt);
6883 bool dropProcedureIfExists(
string name, *
hash opt);
6899 bool dropSequenceIfExists(
string name, *
hash opt);
6915 bool dropViewIfExists(
string name, *
hash opt);
6931 bool dropTableIfExists(
string name, *
hash opt);
6947 *
string getDropFunctionSqlIfExists(
string name, *
hash opt);
6963 *
string getDropProcedureSqlIfExists(
string name, *
hash opt);
6979 *
string getDropSequenceSqlIfExists(
string name, *
hash opt);
6995 *
list getDropTableSqlIfExists(
string name, *
hash opt);
6998 doDropSql(*softlist l,
string type,
string name, *
hash opt);
7001 bool doDrop(*softlist l,
string type,
string name, *
hash opt);
7115 int getNextSequenceValue(
string name);
7128 int getCurrentSequenceValue(
string name);
7141 string getSqlFromList(
list l);
7145 bool supportsSequences();
7149 bool supportsTypes();
7153 bool supportsPackages();
7165 list listFunctions();
7173 list listProcedures();
7181 list listSequences();
7207 bool rebuildIndex(
string name, *
hash options);
7230 computeStatistics(*
hash options);
7241 reclaimSpace(*
hash options);
7246 validateOptionsIntern(
string err,
hash ropt, reference<hash> opt);
7252 validateOptionsIntern(
string err,
hash ropt, reference<hash> opt,
string tag);
7262 static checkDriverOptions(reference<hash> h,
string drv);
7267 hash getDatabaseOptions();
7274 hash getCallbackOptions();
7281 hash getCreationOptions();
7288 hash getCacheOptions();
7295 hash getAlignSchemaOptions();
7302 hash getDropSchemaOptions();
7309 hash getSchemaDescriptionOptions();
7316 hash getSequenceDescriptionOptions();
7323 hash getRebuildIndexOptions();
7330 hash getComputeStatisticsOptions();
7337 hash getReclaimSpaceOptions();
7344 auto tryExecArgsImpl(
string sql, *softlist args);
7351 auto tryExecRawImpl(
string sql);
7357 abstract string getCreateSqlImpl(
list l);
7361 abstract list getAlignSqlImpl(
hash schema_hash, *
hash opt);
7365 abstract list getDropSchemaSqlImpl(
hash schema_hash, *
hash opt);
7400 abstract list featuresImpl();
7404 abstract list listTablesImpl();
7408 abstract list listFunctionsImpl();
7412 abstract list listProceduresImpl();
7416 abstract list listSequencesImpl();
7420 abstract list listViewsImpl();
7426 abstract int getNextSequenceValueImpl(
string name);
7431 abstract int getCurrentSequenceValueImpl(
string name);
7437 abstract bool supportsSequencesImpl();
7441 abstract bool supportsPackagesImpl();
7445 abstract bool supportsTypesImpl();
7450 abstract bool rebuildIndexImpl(
string name, *
hash options);
7454 abstract computeStatisticsImpl(*
hash options);
7458 abstract reclaimSpaceImpl(*
hash options);
7501 constructor(AbstractDatasource ds,
string name, *
hash opts);
7517 constructor(
string ds,
string name, *
hash opts);
7541 constructor(
hash ds,
string name, *
hash opts);
7553 constructor(AbstractDatasource ds,
hash desc,
string name, *
hash opts);
7563 any methodGate(
string meth);
7580 const TableOptions = (
7582 "table_cache":
"Tables",
7590 const IndexOptions = (
7598 const ConstraintOptions = IndexOptions;
7601 const CacheOptions = (
7602 "table_cache":
"Tables",
7609 const ForeignConstraintOptions = ConstraintOptions + (
7610 "table_cache":
"Tables",
7621 const SelectOptions = (
7626 "where":
"hash/list",
7627 "orderby":
"softstringinthashlist",
7632 "groupby":
"softstringinthashlist",
7639 const TableOmissionOptions = (
7641 "foreign_constraints":
True,
7650 "omit":
"softstringlist",
7662 const AlignTableOptions = TableCreationOptions + (
7667 "db_table_cache":
"Tables",
7683 const TableDescriptionHashOptions = (
7691 "table_cache":
"Tables",
7707 const ColumnDescOptions = (
7723 const AdditionalColumnDescOptions = (
7728 const ColumnOptions = {};
7735 const SqlDataCallbackOptions = (
7736 "sqlarg_callback":
"code",
7737 "tablecode":
"code",
7750 const InsertOptions = SqlDataCallbackOptions + (
7751 "returning":
"stringhashlist",
7761 const UpsertOptions = (
7762 "info_callback":
"code",
7765 "omit_update":
"softstringlist",
7773 const InsertFromIteratorOptions = SqlDataCallbackOptions + (
7774 "info_callback":
"code",
7799 const UpsertInsertFirst = 1;
7807 const UpsertUpdateFirst = 2;
7816 const UpsertSelectFirst = 3;
7823 const UpsertAuto = 4;
7830 const UpsertInsertOnly = 5;
7837 const UpsertUpdateOnly = 6;
7842 const UpsertStrategyMap = (
7843 UpsertInsertFirst:
"UpsertInsertFirst",
7844 UpsertUpdateFirst:
"UpsertUpdateFirst",
7845 UpsertSelectFirst:
"UpsertSelectFirst",
7846 UpsertAuto:
"UpsertAuto",
7847 UpsertInsertOnly:
"UpsertInsertOnly",
7848 UpsertUpdateOnly:
"UpsertUpdateOnly",
7854 const UpsertStrategyDescriptionMap = (
7855 "UpsertInsertFirst": UpsertInsertFirst,
7856 "UpsertUpdateFirst": UpsertUpdateFirst,
7857 "UpsertSelectFirst": UpsertSelectFirst,
7858 "UpsertAuto": UpsertAuto,
7859 "UpsertInsertOnly": UpsertInsertOnly,
7860 "UpsertUpdateOnly": UpsertUpdateOnly,
7868 const UR_Inserted = 1;
7872 const UR_Verified = 2;
7875 const UR_Updated = 3;
7878 const UR_Unchanged = 4;
7881 const UR_Deleted = 5;
7887 const UpsertResultMap = (
7888 UR_Inserted:
"inserted",
7889 UR_Verified:
"verified",
7890 UR_Updated:
"updated",
7891 UR_Unchanged:
"unchanged",
7892 UR_Deleted:
"deleted",
7898 const UpsertResultDescriptionMap = (
7899 "inserted": UR_Inserted,
7900 "verified": UR_Verified,
7901 "updated": UR_Updated,
7902 "unchanged": UR_Unchanged,
7903 "deleted": UR_Deleted,
7907 const UpsertResultLetterMap = (
7952 constructor(AbstractDatasource nds,
string nname, *
hash nopts) ;
7972 setDatasource(AbstractDatasource nds);
7977 doTableOptions(*
hash nopts);
8025 dropCommit(*
hash opt);
8044 deprecated dropNoCommit(*
hash opt);
8058 auto tryExec(
string sql);
8072 auto tryExecArgs(
string sql, *softlist args);
8087 auto tryExecRaw(
string sql);
8102 softlist getDropSql(*
hash opt);
8128 deprecated truncateNoCommit();
8146 string getTruncateSql(*
hash opt);
8159 createCommit(*
hash opt);
8178 deprecated createNoCommit(*
hash opt);
8192 rename(
string new_name, *reference<string> sql, *
Tables table_cache);
8197 doRenameIntern(
string new_name, *
Tables table_cache);
8231 bool emptyUnlocked();
8270 AbstractColumn addColumn(
string cname,
hash opt,
bool nullable = True, *reference lsql);
8303 list getAddColumnSql(
string cname,
hash copt,
bool nullable = True, *
hash opt);
8308 AbstractColumn addColumnUnlocked(
string cname,
hash opt,
bool nullable = True, *reference lsql,
bool do_exec = True,
bool modify_table = True);
8344 AbstractColumn modifyColumn(
string cname,
hash opt,
bool nullable = True, *reference lsql);
8375 list getModifyColumnSql(
string cname,
hash copt,
bool nullable = True, *
hash opt);
8396 AbstractColumn renameColumn(
string old_name,
string new_name, reference<string> sql);
8418 string getRenameColumnSql(
string old_name,
string new_name, *
hash opt);
8429 validateOptionsIntern(
string err,
hash ropt, reference<hash> opt);
8435 validateOptionsIntern(
string err,
hash ropt, reference<hash> opt,
string tag);
8441 execSql(softlist lsql);
8492 string getAddPrimaryKeySql(
string pkname, softlist cols, *
hash pkopt, *
hash opt);
8503 AbstractPrimaryKey addPrimaryKeyUnlocked(
string pkname, softlist cols, *
hash opt, *reference<string> sql);
8509 AbstractPrimaryKey addPrimaryKeyUnlockedIntern(
string pkname, softlist cols, *
hash opt, *reference<string> sql);
8530 list getDropAllConstraintsAndIndexesOnColumnSql(
string cname, *
hash opt);
8535 list getDropAllConstraintsAndIndexesOnColumnSqlUnlocked(
string cname, *
hash opt);
8559 list getDropPrimaryKeySql(*
hash opt);
8630 string getAddUniqueConstraintSql(
string cname, softlist cols, *
hash ukopt, *
hash opt);
8667 AbstractIndex addIndex(
string iname,
bool unique, softlist cols, *
hash opt, *reference<string> sql);
8692 string getAddIndexSql(
string iname,
bool unique, softlist cols, *
hash ixopt, *
hash opt);
8697 AbstractIndex addIndexUnlocked(
string iname,
bool unique, softlist cols, *
hash opt, *reference<string> sql);
8703 AbstractIndex addIndexUnlockedIntern(
string iname,
bool unique, softlist cols, *
hash opt, *reference<string> sql);
8720 AbstractIndex renameIndex(
string old_name,
string new_name, reference<string> sql);
8742 AbstractIndex dropIndex(
string iname, *reference<string> sql);
8765 string getDropIndexSql(
string iname, *
hash opt);
8791 AbstractForeignConstraint addForeignConstraint(
string cname, softlist cols,
string table, *softlist tcols, *
hash opt, *reference<string> sql);
8817 string getAddForeignConstraintSql(
string cname, softlist cols,
string table, *softlist tcols, *
hash fkopt, *
hash opt);
8822 Columns getReferencedTableColumnsUnlocked(
string table, *
Tables cache,
string err =
"FOREIGN-CONSTRAINT-ERROR");
8828 AbstractForeignConstraint addForeignConstraintUnlocked(
string cname, softlist cols,
string table, *softlist tcols, *
hash opt, *reference<string> sql);
8834 AbstractForeignConstraint addForeignConstraintUnlockedIntern(
string cname, softlist cols,
string table, *softlist tcols, *
hash opt, *reference<string> sql);
8926 string getAddCheckConstraintSql(
string cname,
string src, *
hash copt, *
hash opt);
8954 AbstractConstraint renameConstraint(
string old_name,
string new_name, reference lsql);
8977 string getDropConstraintSql(
string cname, *
hash opt);
9000 *
string getDropConstraintIfExistsSql(
string cname, *
hash opt, *reference<AbstractConstraint> cref);
9078 list getAddTriggerSql(
string tname,
string src, *
hash topt, *
hash opt);
9089 AbstractTrigger addTriggerUnlockedIntern(
string tname,
string src, *
hash opt, *reference lsql);
9135 list getDropTriggerSql(
string tname, *
hash opt);
9140 getAllConstraintsUnlocked(*
hash opt);
9146 checkUniqueConstraintName(
string err,
string cname);
9152 checkUniqueConstraintNameValidateOptions(
string err,
string cname,
hash ropt, reference<hash> opt);
9159 validateColumnOptions(
string cname, reference<hash> opt,
bool nullable);
9205 list getDropColumnSql(
string cname, *
hash opt);
9226 *
hash insertCommit(
hash row, reference<string> sql);
9234 *
hash insertCommit(
hash row, reference<string> sql,
hash opt);
9256 *
hash insert(
hash row, reference<string> sql);
9264 *
hash insert(
hash row, reference<string> sql,
hash opt);
9268 deprecated *
hash insertNoCommit(
hash row, *reference<string> sql, *
hash opt);
9275 *
hash insertIntern(
hash row, *reference<string> sql, *
hash opt);
9281 hash getPlaceholdersAndValues(
hash row);
9289 bool hasReturning();
9449 int upsertCommit(
hash row,
int upsert_strategy = UpsertAuto, *
hash opt);
9469 int upsert(
hash row,
int upsert_strategy = UpsertAuto, *
hash opt);
9473 deprecated
int upsertNoCommit(
hash row,
int upsert_strategy = UpsertAuto);
9497 code getUpsertClosure(
hash row,
int upsert_strategy = UpsertAuto, *
hash opt);
9553 code getUpsertClosureWithValidation(
hash example_row,
int upsert_strategy = UpsertAuto, *
hash opt);
9852 *
hash selectRow(*
hash sh, *reference<string> sql, *
hash opt);
9874 *
list selectRows(*
hash sh, *reference<string> sql, *
hash opt);
9896 *
hash select(*
hash sh, *reference<string> sql, *
hash opt);
9982 string getSelectSql(*
hash sh, *reference<list> args);
9988 string getSelectSqlIntern(*
hash qh, reference<list> args, *
hash opt);
9991 string getSelectSqlUnlocked(*
hash qh, reference<list> args, *
hash opt);
9995 string getSelectSqlUnlockedIntern(*
hash qh,
string from, reference<list> args, *
hash ch, *
hash opt);
10000 string getFromIntern(
string from, *
hash qh);
10024 doForUpdate(reference<string> sql);
10030 string getSelectSqlName(*
hash qh);
10036 string getColumnExpressionIntern(
auto cvc, *
hash jch,
bool join, *
hash ch, *
hash psch);
10042 string doColumnOperatorIntern(
hash cvc, *
hash jch,
bool join, *
hash ch, *
hash psch, *reference psch_ref);
10048 string doColumnOperatorIntern(
auto cop,
auto arg, *
string cve,
hash cm, *
hash jch,
bool join, *
hash ch, *
hash psch, *reference psch_ref);
10054 string getColumnNameIntern(
string cv, *
hash jch,
bool join, *
hash ch, *
hash psch);
10061 bool asteriskRequiresPrefix();
10067 getSelectWhereSqlUnlocked(reference<string> sql, reference<list> args, *
hash qh, *
hash jch,
bool join = False, *
hash ch, *
hash psch);
10073 *
string getWhereClause(*
hash cond, reference<list> args, *
string cprefix, *
hash jch,
bool join = False);
10079 *
string getWhereClause(
list cond, reference<list> args, *
string cprefix, *
hash jch,
bool join = False);
10085 *
string getWhereClauseUnlocked(
list cond, reference<list> args, *
string cprefix, *
hash jch,
bool join = False, *
hash pch, *
hash psch);
10091 *
string getWhereClauseUnlocked(*
hash cond, reference<list> args, *
string cprefix, *
hash jch,
bool join = False, *
hash pch, *
hash psch);
10097 *
list getWhereClauseIntern(*
hash cond, reference<list> args, *
string cprefix, *
hash jch,
bool join = False, *
hash ch, *
hash psch);
10103 string doWhereExpressionIntern(
string cn,
auto we, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch);
10107 string getOrClause(
list arglist, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch);
10110 string getOrClause(
hash arg, reference<list> args, *
hash jch,
bool join = False, *
hash ch, *
hash psch);
10115 doSelectOrderBySqlUnlocked(reference<string> sql, reference<list> args, *
hash qh, *
hash jch, *
hash ch, *
hash psch,
list coll);
10135 int delCommit(
hash cond, reference<string> sql,
hash opt);
10139 int delCommit(
hash cond,
hash opt);
10143 int delCommit(
hash cond, reference<string> sql);
10147 int delCommit(
hash cond);
10170 int del(
hash cond, reference<string> sql,
hash opt);
10178 int del(
hash cond, reference<string> sql);
10182 int del(
hash cond);
10190 deprecated
int delNoCommit(*
hash cond, *reference<string> sql);
10194 int delIntern(*
hash cond, *reference<string> sql, *
hash opt);
10216 int updateCommit(
hash set,
hash cond, reference<string> sql,
hash opt);
10220 int updateCommit(
hash set,
hash cond, reference<string> sql);
10228 int updateCommit(
hash set,
hash cond);
10232 int updateCommit(
hash set);
10253 int update(
hash set,
hash cond, reference<string> sql,
hash opt);
10257 int update(
hash set,
hash cond, reference<string> sql);
10269 int update(
hash set);
10273 deprecated
int updateNoCommit(
hash set, *
hash cond, *reference<string> sql);
10276 deprecated
int updateNoCommit(
hash set, *
hash cond, *
hash opt);
10280 int updateIntern(
hash set, *
hash cond, *reference<string> sql, *
hash opt);
10286 string getUpdateExpression(
string col, hash<UpdateOperatorInfo> uh);
10292 bool emptyDataIntern();
10298 Columns checkUpsertRow(
hash row, reference<int> upsert_strategy);
10304 code getUpsertInsertFirst(
Columns cols,
hash example_row, *
hash opt);
10310 code getUpsertUpdateFirst(
Columns cols,
hash example_row, *
hash opt);
10316 code getUpsertSelectFirst(
Columns cols,
hash example_row, *
hash opt);
10334 Columns getUpsertColumns(reference csrc);
10340 string getUpsertSelectSql(
hash row,
Columns cols, reference<list<string>> updc);
10346 string getUpsertInsertSql(
hash row);
10352 string getUpsertUpdateSql(
hash row,
Columns cols, reference updc, *
hash opt);
10364 checkValue(
string cname,
string argname, reference val,
string type);
10378 string getSqlFromList(
list l);
10393 string getSqlValue(
auto v);
10512 string getRenameSql(
string new_name, *
hash opt);
10525 string getCreateSqlString(*
hash opt);
10553 string getCreateTableSql(*
hash opt);
10561 bool checkExistence();
10566 *
hash getCheckOmissionOptions(*softlist ol,
string err);
10637 *
list getCreateIndexesSql(*
hash opt,
bool cache = True);
10653 *
string getCreatePrimaryKeySql(*
hash opt,
bool cache = True);
10669 *
list getCreateForeignConstraintsSql(*
hash opt,
bool cache = True);
10687 *
list getCreateConstraintsSql(*
hash opt,
bool cache = True);
10703 *
list getCreateMiscSql(*
hash opt,
bool cache = True);
10721 *
list getCreateTriggersSql(*
hash opt,
bool cache = True);
10732 *
hash find(
auto id);
10752 string getPrimaryKeyColumn();
10816 string getBaseType();
10820 string getSqlName();
10824 string getColumnSqlName(
string col);
10828 list getColumnSqlNames(softlist cols);
10834 bool bindEmptyStringsAsNull();
10838 abstract bool hasArrayBind();
10845 hash getTableOptions();
10854 hash getForeignConstraintOptions();
10863 hash getConstraintOptions();
10872 hash getCacheOptions();
10881 hash getTableCreationOptions();
10890 hash getAlignTableOptions();
10899 hash getTableDescriptionHashOptions();
10908 hash getColumnOptions();
10917 hash getColumnDescOptions();
10926 hash getTableColumnDescOptions();
10935 hash getIndexOptions();
10944 hash getTriggerOptions();
10953 hash getSelectOptions();
10962 hash getUpsertOptions();
10971 hash getInsertOptions();
10980 hash getInsertFromIteratorOptions();
10989 hash getSqlDataCallbackOptions();
10998 hash getWhereOperatorMap();
11007 hash getColumnOperatorMap();
11014 *
hash getColumnOperatorMapImpl();
11055 addCustomCopOperator(
string name,
hash operator);
11063 hash getInsertOperatorMap();
11072 hash getUpdateOperatorMap();
11081 hash getRawUpdateOperatorMap();
11090 *
hash getPseudoColumnHash();
11096 string getCreateTableSqlUnlocked(*
hash opt);
11102 *
list getCreateIndexesSqlUnlocked(*
hash opt,
bool cache = True);
11108 *
string getCreatePrimaryKeySqlUnlocked(*
hash opt,
bool cache = True);
11114 *
list getCreateConstraintsSqlUnlocked(*
hash opt,
bool cache = True);
11120 *
list getCreateForeignConstraintsSqlUnlocked(*
hash opt,
bool cache = True);
11126 *
list getCreateMiscSqlUnlocked(*
hash opt,
bool cache = True);
11132 *
list getCreateTriggersSqlUnlocked(*
hash opt,
bool cache = True);
11138 list getCreateSqlUnlocked(*
hash opt,
bool cache = True);
11144 cacheUnlocked(*
hash opt);
11150 auto execData(*
hash opt,
string sql, *
list args);
11156 execData(SQLStatement stmt, *
hash opt, *
list args);
11160 static AbstractTable getTable(AbstractDatasource nds,
string nname, *
hash opts);
11168 getColumnsUnlocked();
11174 getPrimaryKeyUnlocked();
11181 getIndexesUnlocked();
11187 getForeignConstraintsUnlocked(*
hash opt);
11199 getConstraintsUnlocked();
11205 getTriggersUnlocked();
11212 bool hasReturningImpl();
11218 softlist getDropSqlImpl();
11224 string getTruncateSqlImpl();
11231 auto tryExecArgsImpl(
string sql, *softlist args);
11238 auto tryExecRawImpl(
string sql);
11251 preSetupTableImpl(reference desc, *
hash opt);
11257 abstract *
hash doReturningImpl(
hash opt, reference<string> sql,
list args);
11262 abstract bool emptyImpl();
11268 abstract *
string getSqlValueImpl(
auto v);
11277 abstract bool checkExistenceImpl();
11283 abstract bool supportsTablespacesImpl();
11289 abstract bool constraintsLinkedToIndexesImpl();
11295 abstract bool uniqueIndexCreatesConstraintImpl();
11300 abstract setupTableImpl(
hash desc, *
hash opt);
11305 abstract Columns describeImpl();
11313 abstract Indexes getIndexesImpl();
11325 abstract Triggers getTriggersImpl();
11330 abstract string getCreateTableSqlImpl(*
hash opt);
11334 abstract *
list getCreateMiscSqlImpl(*
hash opt,
bool cache);
11338 abstract string getCreateSqlImpl(
list l);
11342 abstract string getRenameSqlImpl(
string new_name);
11351 abstract AbstractColumn addColumnImpl(
string cname,
hash opt,
bool nullable = True);
11382 abstract bool tryInsertImpl(
string sql,
hash row);
11388 abstract hash getQoreTypeMapImpl();
11394 abstract hash getTypeMapImpl();
11400 abstract doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *
hash qh, *
hash jch, *
hash ch, *
hash psch,
list coll);
11406 abstract doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *
hash qh);
string name
the name of the constraint
Definition: SqlUtil.qm.dox.h:5785
hash< ColumnOperatorInfo > cop_first_value(any column)
Analytic/window function: value evaluated at the row that is the first row of the window frame...
nothing rename(string old_path, string new_path)
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:6072
const COP_SEQ
to return the next value of a sequence
Definition: SqlUtil.qm.dox.h:2339
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2144
any column
column sopecifier, may be a string or a complex hash
Definition: SqlUtil.qm.dox.h:2131
const UpsertAuto
Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst...
Definition: SqlUtil.qm.dox.h:7823
const DefaultIopMap
a hash of default insert operator descriptions (currently empty, all operators are driver-dependent) ...
Definition: SqlUtil.qm.dox.h:4813
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:5151
hash< ColumnOperatorInfo > cop_append(auto column, string arg)
returns a ColumnOperatorInfo hash for the "append" operator with the given argument ...
string native_type
the native database column type; if both native_type and qore_type are given then native_type is used...
Definition: SqlUtil.qm.dox.h:2103
string cop
the column operator string code
Definition: SqlUtil.qm.dox.h:2130
string sprintf(string fmt,...)
int delCommit()
SqlUtil::AbstractTable::delCommit() variant
const OP_IN
the SQL "in" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4331
the base abstract class for the table implementation
Definition: SqlUtil.qm.dox.h:7571
const DefaultCopMap
a hash of default column operator descriptions
Definition: SqlUtil.qm.dox.h:2430
hash< ColumnOperatorInfo > cop_cast(auto column, string arg, auto arg1, auto arg2)
returns a ColumnOperatorInfo hash for the "cast" operator with the given argument(s) ...
const VARCHAR
specifies a VARCHAR column (equivalent to Qore::Type::String)
Definition: SqlUtil.qm.dox.h:2190
const COP_FIRST_VALUE
Analytic (window) function: FIRST_VALUE.
Definition: SqlUtil.qm.dox.h:2391
hash< ColumnOperatorInfo > cop_multiply(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "*" operator with the given arguments
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:5243
bool updatable
Flag showing if is the view updatable with DML commands.
Definition: SqlUtil.qm.dox.h:6120
insert operator info hash as returned by all insert operator functions
Definition: SqlUtil.qm.dox.h:2136
hash< OperatorInfo > op_ne(auto arg)
returns an OperatorInfo hash for the "!=" or "<>" operator with the given argument for use in where c...
string printf(string fmt,...)
const OP_BETWEEN
the SQL "between" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4326
*AbstractColumnSupportingConstraint constraint
the AbstractColumnSupportingConstraint that this index supports, if any
Definition: SqlUtil.qm.dox.h:5679
*hash upsertFromSelectCommit(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...
hash< ColumnOperatorInfo > make_cop(string cop, auto column, auto arg)
returns a ColumnOperatorInfo hash
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2138
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:5662
const OP_OR
to combine SQL expressions with "or" for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4344
const COP_OVER
the SQL "over" clause
Definition: SqlUtil.qm.dox.h:2294
hash< ColumnOperatorInfo > cop_as(auto column, string arg)
returns a ColumnOperatorInfo hash for the "as" operator with the given argument
foreign constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:5977
hash< ColumnOperatorInfo > cop_minus(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "-" operator with the given arguments
hash< ColumnOperatorInfo > cop_last_value(any column)
Analytic/window function: value evaluated at the row that is the last row of the window frame...
const COP_DENSE_RANK
Analytic (window) function: DENSE_RANK.
Definition: SqlUtil.qm.dox.h:2384
const OP_NE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4286
hash< ColumnOperatorInfo > cop_rank()
Analytic/window function: rank of the current row with gaps.
hash< InsertOperatorInfo > iop_seq_currval(string arg)
returns an InsertOperatorInfo hash for retrieving the current value of the given sequence in insert q...
const COP_SUM
to return the sum value
Definition: SqlUtil.qm.dox.h:2284
string name
the name of the object
Definition: SqlUtil.qm.dox.h:6150
a class describing a foreign constraint target
Definition: SqlUtil.qm.dox.h:6024
hash< ColumnOperatorInfo > cop_length(auto column)
returns a ColumnOperatorInfo hash for the "len" operator with the given argument; returns the length ...
*string qore_type
the equivalent qore type name of the column if known
Definition: SqlUtil.qm.dox.h:5494
const COP_SEQ_CURRVAL
to return the last value of a sequence issued in the same session
Definition: SqlUtil.qm.dox.h:2344
the base class to use to extend AbstractColumn to implement numeric columns
Definition: SqlUtil.qm.dox.h:5598
int upsert(hash row, int upsert_strategy=UpsertAuto, *hash opt)
update or insert the data in the table according to the hash argument; the table must have a unique k...
hash< InsertOperatorInfo > make_iop(string iop, auto arg)
returns an InsertOperatorInfo hash
const JopMap
a hash of valid join operators
Definition: SqlUtil.qm.dox.h:3787
const SZ_MAND
the data type takes a mandatory size parameter
Definition: SqlUtil.qm.dox.h:2213
const OP_GT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4276
const CHAR
specifies a CHAR column
Definition: SqlUtil.qm.dox.h:2196
const COP_AVG
to return the average value
Definition: SqlUtil.qm.dox.h:2279
const DB_SEQUENCES
Feature: sequences.
Definition: SqlUtil.qm.dox.h:2174
const DB_MVIEWS
Feature: materialized views / snapshots.
Definition: SqlUtil.qm.dox.h:2168
const JOP_LEFT
for left outer joins
Definition: SqlUtil.qm.dox.h:3779
base class for sequences
Definition: SqlUtil.qm.dox.h:6067
*hash upsertFromIteratorCommit(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...
const COP_LAST_VALUE
Analytic (window) function: LAST_VALUE.
Definition: SqlUtil.qm.dox.h:2398
hash< OperatorInfo > op_clt(string arg)
returns an OperatorInfo hash for the "<" operator with the given argument for use in where clauses wh...
bool nullable
True if the column can hold a NULL value, False if not
Definition: SqlUtil.qm.dox.h:5500
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2125
const UpsertOptions
default upsert option keys
Definition: SqlUtil.qm.dox.h:7761
number number(softnumber n)
const COP_DISTINCT
to return distinct values
Definition: SqlUtil.qm.dox.h:2264
hash< OperatorInfo > op_cge(string arg)
returns an OperatorInfo hash for the ">=" operator with the given argument for use in where clauses w...
const COP_YEAR_HOUR
to return a date value with year to hextern information
Definition: SqlUtil.qm.dox.h:2334
*hash opt
optional join options (for example, to specify a partition for the join if supported) ...
Definition: SqlUtil.qm.dox.h:2156
ForeignConstraints foreignConstraints
foreign constraints description
Definition: SqlUtil.qm.dox.h:7927
*list selectRows(*hash sh, *reference< string > sql, *hash opt)
returns a list of hashes representing the rows in the table that match the argument hash ...
hash< UpdateOperatorInfo > uop_multiply(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "*" operator with the given arguments
hash< ColumnOperatorInfo > cop_plus(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "+" operator with the given arguments
hash< ColumnOperatorInfo > cop_value(auto arg)
returns a ColumnOperatorInfo hash for the "value" (literal) operator with the given argument ...
any table
the table to join with (either an AbstractTable object or a string table name)
Definition: SqlUtil.qm.dox.h:2151
hash< UpdateOperatorInfo > uop_substr(int start, *int count, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "substr" operator with the given arguments; returns a subs...
string jop
the join operator string code
Definition: SqlUtil.qm.dox.h:2150
const IOP_SEQ_CURRVAL
for using the last value of a sequence issued in the current session
Definition: SqlUtil.qm.dox.h:4810
base class for abstract SqlUtil classes
Definition: SqlUtil.qm.dox.h:6390
const UpsertUpdateFirst
Upsert option: update first, if the update fails, then insert.
Definition: SqlUtil.qm.dox.h:7807
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference< string > sql, *hash opt)
returns an SQLStatement object that will iterate the results of a select statement matching the argum...
hash< ColumnOperatorInfo > cop_year_day(auto column)
returns a ColumnOperatorInfo hash for the "year_day" operator with the given argument ...
const OP_CNE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4316
hash< UpdateOperatorInfo > uop_prepend(string arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "prepend" operator with the given argument ...
represents a database; this class embeds an AbstractDatabase object that is created automatically in ...
Definition: SqlUtil.qm.dox.h:6320
const SqlUtilDrivers
known drivers
Definition: SqlUtil.qm.dox.h:4860
const OP_CGT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4306
the base class for foreign key constraint information
Definition: SqlUtil.qm.dox.h:6046
ForeignConstraintTarget target
a ForeignConstraintTarget object to describe the target table and columns
Definition: SqlUtil.qm.dox.h:6051
hash< OperatorInfo > op_le(auto arg)
returns an OperatorInfo hash for the "<=" operator with the given argument for use in where clauses w...
int insertFromSelect(list cols, AbstractTable source, hash sh, reference< string > sql, hash opt)
inserts rows into a table based on a select statement from another table (which must be using the sam...
hash< string, hash< JoinOperatorInfo > > join_right_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for right outer joins with the given arguments for use when joining with a table other...
int scale
the scale for numeric columns
Definition: SqlUtil.qm.dox.h:5603
hash< string, hash< JoinOperatorInfo > > join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for standard inner joins with the given arguments
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy=UpsertAuto, *hash opt)
returns a closure that can be executed given a hash argument representing a single row that will be u...
abstract class for check constraints
Definition: SqlUtil.qm.dox.h:5841
hash< UpdateOperatorInfo > uop_divide(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "/" operator with the given arguments
const COP_COUNT
to return the row count
Definition: SqlUtil.qm.dox.h:2289
const OP_CEQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4321
const COP_NTILE
Analytic (window) function: NTILE.
Definition: SqlUtil.qm.dox.h:2405
hash< UpdateOperatorInfo > uop_plus(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "+" operator with the given arguments
softint scale
for numeric data types, this value gives the scale
Definition: SqlUtil.qm.dox.h:2107
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:4869
hash< ColumnOperatorInfo > cop_year_hour(auto column)
returns a ColumnOperatorInfo hash for the "year_hour" operator with the given argument ...
join operator info hash as returned by all join operator functions
Definition: SqlUtil.qm.dox.h:2149
any default_value
the default value for the column
Definition: SqlUtil.qm.dox.h:2109
string name
the table's name
Definition: SqlUtil.qm.dox.h:7919
hash< OperatorInfo > op_cne(string arg)
returns an OperatorInfo hash for the "!=" or "<>" operator with the given argument for use in where c...
trigger container class that throws an exception if an unknown trigger is accessed ...
Definition: SqlUtil.qm.dox.h:6272
int updateCommit(hash set, hash cond, reference< string > sql, hash opt)
updates rows in the table matching an optional condition and returns the count of rows updated; the t...
any arg
optional argument
Definition: SqlUtil.qm.dox.h:2132
string getSelectSql(*hash sh, *reference< list > args)
returns the SQL string to be executed corresponding to the argument hash with an output parameter for...
int index(softstring str, softstring substr, softint pos=0)
string src
the source of the check clause
Definition: SqlUtil.qm.dox.h:5846
Indexes indexes
index descriptions
Definition: SqlUtil.qm.dox.h:7925
const DT_DAY
Format unit: day.
Definition: SqlUtil.qm.dox.h:3509
hash< OperatorInfo > op_cle(string arg)
returns an OperatorInfo hash for the "<=" operator with the given argument for use in where clauses w...
const DB_PACKAGES
Feature: packages.
Definition: SqlUtil.qm.dox.h:2170
hash< ColumnOperatorInfo > cop_avg(auto column)
returns a ColumnOperatorInfo hash for the "avg" operator; returns average column values ...
const COP_UPPER
to return column value in upper case
Definition: SqlUtil.qm.dox.h:2254
hash< string, hash< JoinOperatorInfo > > join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for right outer joins with the given arguments
code getUpsertClosure(hash row, int upsert_strategy=UpsertAuto, *hash opt)
returns a closure that can be executed given a hash argument representing a single row that will be u...
*hash cond
additional conditions for the join clause for the table argument; see Where Clauses for more informat...
Definition: SqlUtil.qm.dox.h:2154
const COP_PLUS
the SQL "plus" operator
Definition: SqlUtil.qm.dox.h:2304
const OP_GE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4281
index container class that throws an exception if an unknown index is accessed
Definition: SqlUtil.qm.dox.h:5616
const SZ_NUM
the data type is numeric so takes an optional precision and scale
Definition: SqlUtil.qm.dox.h:2219
hash< OperatorInfo > op_between(auto l, auto r)
returns an OperatorInfo hash for the "between" operator with the given arguments, neither of which ca...
*bool auto_increment
True for DBs that support an auto-increment column
Definition: SqlUtil.qm.dox.h:2119
*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...
const DB_SYNONYMS
Feature: synonyms.
Definition: SqlUtil.qm.dox.h:2182
*string def_val
default value for column
Definition: SqlUtil.qm.dox.h:5503
AbstractPrimaryKey primaryKey
primary key description
Definition: SqlUtil.qm.dox.h:7923
hash< UpdateOperatorInfo > uop_upper(*hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "upper" operator with the given argument; returns a column...
const COP_COALESCE
to return the first non-null argument in the list
Definition: SqlUtil.qm.dox.h:2349
string op
the operator string code
Definition: SqlUtil.qm.dox.h:2124
hash< ColumnOperatorInfo > cop_min(auto column)
returns a ColumnOperatorInfo hash for the "min" operator; returns minimum column values ...
hash< OperatorInfo > op_ge(auto arg)
returns an OperatorInfo hash for the ">=" operator with the given argument for use in where clauses w...
Triggers triggers
trigger descriptions
Definition: SqlUtil.qm.dox.h:7931
const DB_PROCEDURES
Feature: procedures.
Definition: SqlUtil.qm.dox.h:2172
const CreationOptions
default generic creation options
Definition: SqlUtil.qm.dox.h:6584
const OP_EQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4291
generic column description hash in schema descriptions
Definition: SqlUtil.qm.dox.h:2099
int del()
SqlUtil::AbstractTable::del() variant
*string comment
comment on the column
Definition: SqlUtil.qm.dox.h:5506
hash< ColumnOperatorInfo > cop_coalesce(auto col1, auto col2)
returns a ColumnOperatorInfo hash for the "coalesce" operator with the given column arguments; the fi...
string src
the source code
Definition: SqlUtil.qm.dox.h:6117
bool unique
True if the index is a unique index, False if not
Definition: SqlUtil.qm.dox.h:5670
hash< ColumnOperatorInfo > cop_trunc_date(auto column, string mask)
Truncates a date column or value regarding the given mask. The resulting value remains Qore::date (no...
hash< ColumnOperatorInfo > cop_dense_rank()
Analytic/window function: rank of the current row without gaps.
hash< OperatorInfo > op_eq(auto arg)
returns an OperatorInfo hash for the "=" operator with the given argument for use in where clauses wh...
const COP_YEAR_MONTH
to return a date value with year to month information
Definition: SqlUtil.qm.dox.h:2324
string src
the source of the object
Definition: SqlUtil.qm.dox.h:6156
const COP_MAX
to return the maximum value
Definition: SqlUtil.qm.dox.h:2274
hash< OperatorInfo > op_cgt(string arg)
returns an OperatorInfo hash for the ">" operator with the given argument for use in where clauses wh...
const COP_LENGTH
to get the length of a text field
Definition: SqlUtil.qm.dox.h:2361
const COP_AS
to rename a column on output
Definition: SqlUtil.qm.dox.h:2229
hash< string, hash< JoinOperatorInfo > > join_left_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for left outer joins with the given arguments for use when joining with a table other ...
Columns columns
column description object
Definition: SqlUtil.qm.dox.h:7921
const DB_VIEWS
Feature: views.
Definition: SqlUtil.qm.dox.h:2180
hash< ColumnOperatorInfo > cop_max(auto column)
returns a ColumnOperatorInfo hash for the "max" operator; returns maximum column values ...
const OP_LE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4271
const BLOB
specifies a large variable-length binary column (ie BLOB or BYTEA, etc)
Definition: SqlUtil.qm.dox.h:2199
string name
the name of the index
Definition: SqlUtil.qm.dox.h:5667
string _iop
the insert operator string code
Definition: SqlUtil.qm.dox.h:2137
Columns columns
columns in the target table
Definition: SqlUtil.qm.dox.h:6032
string uop
the update operator string code
Definition: SqlUtil.qm.dox.h:2143
const OP_CLE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4301
the API for a constraint with columns
Definition: SqlUtil.qm.dox.h:5871
const DB_TABLES
Feature: tables.
Definition: SqlUtil.qm.dox.h:2176
hash< UpdateOperatorInfo > uop_append(string arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "append" or concatenate operator with the given argument ...
hash< UpdateOperatorInfo > uop_seq_currval(string seq)
returns an UpdateOperatorInfo hash for the "seq" operator with the given argument giving the sequence...
hash< ColumnOperatorInfo > cop_ntile(int value)
Analytic/window function: integer ranging from 1 to the argument value, dividing the partition as equ...
const CLOB
specifies a large variable-length character column (ie CLOB or TEXT, etc)
Definition: SqlUtil.qm.dox.h:2202
const OP_NOT
the SQL "not" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4336
Columns columns
an object of class Columns representing the columns in the index
Definition: SqlUtil.qm.dox.h:5673
base class for function or objects with code
Definition: SqlUtil.qm.dox.h:6145
const DB_TYPES
Feature: named types.
Definition: SqlUtil.qm.dox.h:2178
update operator info hash as returned by all update operator functions
Definition: SqlUtil.qm.dox.h:2142
hash< string, hash< JoinOperatorInfo > > make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt)
returns hash keyed with the table name assigned to a JoinOperatorInfo hash
const COP_CUME_DIST
Analytic (window) function: CUME_DIST.
Definition: SqlUtil.qm.dox.h:2377
hash< ColumnOperatorInfo > cop_lower(auto column)
returns a ColumnOperatorInfo hash for the "lower" operator with the given argument; returns a column ...
hash< ColumnOperatorInfo > cop_distinct(auto column)
returns a ColumnOperatorInfo hash for the "distinct" operator with the given argument; returns distin...
const UpsertResultMap
hash mapping upsert results to a description
Definition: SqlUtil.qm.dox.h:7887
string name
the name of the column
Definition: SqlUtil.qm.dox.h:5488
hash< ColumnOperatorInfo > cop_year(auto column)
returns a ColumnOperatorInfo hash for the "year" operator with the given argument ...
AbstractDatasource ds
the connection to the database server
Definition: SqlUtil.qm.dox.h:6395
hash< UpdateOperatorInfo > uop_lower(*hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "lower" operator with the given argument; returns a column...
hash< string, hash< OperatorInfo > > wop_or(hash h1, hash h2)
returns an OperatorInfo hash with a fake "_OR_" column name; the list of arguments to the function is...
base class for functions
Definition: SqlUtil.qm.dox.h:6190
const COP_MULTIPLY
the SQL "multiply" operator
Definition: SqlUtil.qm.dox.h:2314
column operator info hash as returned by all column operator functions
Definition: SqlUtil.qm.dox.h:2129
hash< ColumnOperatorInfo > cop_count(auto column="")
returns a ColumnOperatorInfo hash for the "count" operator; returns row counts
Constraints constraints
constraint descriptions
Definition: SqlUtil.qm.dox.h:7929
hash< ColumnOperatorInfo > cop_cume_dist()
Analytic/window function: relative rank of the current row.
const COP_PREPEND
to prepend a string to a column on output
Definition: SqlUtil.qm.dox.h:2239
const COP_TRUNC_DATE
to return the date with truncated value
Definition: SqlUtil.qm.dox.h:2370
base class for views
Definition: SqlUtil.qm.dox.h:6106
hash< OperatorInfo > op_like(string str)
returns an OperatorInfo hash for the "like" operator with the given argument for use in where clauses...
*hash opts
option hash
Definition: SqlUtil.qm.dox.h:6401
*hash select(*hash sh, *reference< string > sql, *hash opt)
returns a hash of lists representing the columns and rows in the table that match the argument hahs ...
*list findAll(*hash cond)
finds all rows in the table with the given column values; a list of hashes is returned representing t...
hash< string, hash< JoinOperatorInfo > > join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for left outer joins with the given arguments
string type
the type of object
Definition: SqlUtil.qm.dox.h:6153
hash< ColumnOperatorInfo > cop_seq(string seq, *string as)
returns a ColumnOperatorInfo hash for the "seq" operator with the given argument giving the sequence ...
const COP_YEAR
to return a date value with year information only
Definition: SqlUtil.qm.dox.h:2319
hash< string, hash< JoinOperatorInfo > > join_inner_alias(string ta, string table_name, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for standard inner joins with the given arguments for use when joining with a table ot...
string string(softstring str, *string enc)
int insertFromSelectCommit(list cols, AbstractTable source, hash sh, reference< string > sql, hash opt)
inserts rows into a table based on a select statement from another table (which must be using the sam...
int size
the size of the column
Definition: SqlUtil.qm.dox.h:5497
hash< string, hash > driver
this key can optionally contain a hash keyed by driver name which contains a hash of values that will...
Definition: SqlUtil.qm.dox.h:2117
string native_type
the native type name of the column
Definition: SqlUtil.qm.dox.h:5491
const COP_VALUE
to append a constant value (SQL Literal) to use as an output column value
Definition: SqlUtil.qm.dox.h:2249
hash< UpdateOperatorInfo > uop_seq(string seq)
returns an UpdateOperatorInfo hash for the "seq" operator with the given argument giving the sequence...
column container class that throws an exception if an unknown column is accessed
Definition: SqlUtil.qm.dox.h:5431
the base class for triggers
Definition: SqlUtil.qm.dox.h:6254
*string ta
optional table name or alias of the other table to join with when not joining with the primary table ...
Definition: SqlUtil.qm.dox.h:2155
const OP_LT
the SQL less than (<) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4266
string dsdesc
datasource description
Definition: SqlUtil.qm.dox.h:6397
*hash findSingle(*hash cond)
finds a single row in the table that match the row condition passed; multiple rows may match...
hash< ColumnOperatorInfo > cop_sum(auto column)
returns a ColumnOperatorInfo hash for the "sum" operator; returns the total sum of a numeric column...
function container class that throws an exception if an unknown function is accessed ...
Definition: SqlUtil.qm.dox.h:6216
const UR_Unchanged
row was unchanged (only possible with UpsertSelectFirst, UpsertInsertOnly, and UpsertUpdateOnly) ...
Definition: SqlUtil.qm.dox.h:7878
AbstractDatabase db
the embedded AbstractDatabase object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:6325
the base class for column information
Definition: SqlUtil.qm.dox.h:5483
const COP_CAST
to convert column value into another datatype
Definition: SqlUtil.qm.dox.h:2234
hash< OperatorInfo > op_in()
returns an OperatorInfo hash for the "in" operator with all arguments passed to the function; for use...
const UpsertInsertOnly
Upsert option: insert if the row does not exist, otherwise ignore.
Definition: SqlUtil.qm.dox.h:7830
const OP_CGE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4311
const DT_MINUTE
Format unit: minute.
Definition: SqlUtil.qm.dox.h:3515
hash< ColumnOperatorInfo > cop_seq_currval(string seq, *string as)
returns a ColumnOperatorInfo hash for the "seq_currval" operator with the given argument giving the s...
const DT_HOUR
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3512
represents a database table; this class embeds an AbstractTable object that is created automatically ...
Definition: SqlUtil.qm.dox.h:7479
*string comment
an optional comment for the column
Definition: SqlUtil.qm.dox.h:2113
hash< ColumnOperatorInfo > cop_divide(auto column1, auto column2)
returns a ColumnOperatorInfo hash for the "/" operator with the given arguments
const DefaultUopMap
a hash of valid update operators
Definition: SqlUtil.qm.dox.h:3529
const COP_MIN
to return the minimum value
Definition: SqlUtil.qm.dox.h:2269
const UpsertSelectFirst
Upsert option: select first, if the row is unchanged, do nothing, if it doesn't exist, insert, otherwise update.
Definition: SqlUtil.qm.dox.h:7816
const COP_YEAR_DAY
to return a date value with year to day information
Definition: SqlUtil.qm.dox.h:2329
hash< OperatorInfo > op_gt(auto arg)
returns an OperatorInfo hash for the ">" operator with the given argument for use in where clauses wh...
const UpsertInsertFirst
Upsert option: insert first, if the insert fails, then update.
Definition: SqlUtil.qm.dox.h:7799
const DT_MONTH
Format unit: month.
Definition: SqlUtil.qm.dox.h:3506
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:6114
const COP_PERCENT_RANK
Analytic (window) function: PERCENT_RANK.
Definition: SqlUtil.qm.dox.h:2412
*hash jcols
the columns to use for the join, the keys will be columns in the source table and the values are colu...
Definition: SqlUtil.qm.dox.h:2153
*number max
the ending number
Definition: SqlUtil.qm.dox.h:6081
const COP_RANK
Analytic (window) function: RANK.
Definition: SqlUtil.qm.dox.h:2419
hash< OperatorInfo > op_not(hash arg)
returns an OperatorInfo hash for the "not" operator; for use in where clauses
number increment
the increment
Definition: SqlUtil.qm.dox.h:6078
hash< ColumnOperatorInfo > cop_row_number()
Analytic/window function: number of the current row within its partition, counting from 1...
const OP_LIKE
the SQL "like" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4261
hash< OperatorInfo > op_lt(auto arg)
returns an OperatorInfo hash for the "<" operator with the given argument for use in where clauses wh...
hash< OperatorInfo > make_op(string op, auto arg)
returns an OperatorInfo hash
hash< OperatorInfo > op_substr(int start, *int count, string text)
returns an OperatorInfo hash for the "substr" operator with the given arguments; for use in where cla...
const SZ_NONE
the data type does not take a size parameter
Definition: SqlUtil.qm.dox.h:2210
hash< UpdateOperatorInfo > uop_minus(auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash for the "-" operator with the given arguments
AbstractTable t
the embedded AbstractTable object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:7484
hash< ColumnOperatorInfo > cop_upper(auto column)
returns a ColumnOperatorInfo hash for the "upper" operator with the given argument; returns a column ...
const OP_CLT
the SQL less than (<) operator for use in Where Clauses when comparing two columns ...
Definition: SqlUtil.qm.dox.h:4296
const COP_MINUS
the SQL "minus" operator
Definition: SqlUtil.qm.dox.h:2299
hash< ColumnOperatorInfo > cop_percent_rank()
Analytic/window function: relative rank of the current row.
string table
the name of the target table
Definition: SqlUtil.qm.dox.h:6029
hash< ColumnOperatorInfo > cop_over(auto column, *string partitionby, *string orderby)
returns a ColumnOperatorInfo hash for the "over" clause
hash< ColumnOperatorInfo > cop_year_month(auto column)
returns a ColumnOperatorInfo hash for the "year_month" operator with the given argument ...
*string alias
optional alias for table in the query
Definition: SqlUtil.qm.dox.h:2152
const COP_SUBSTR
to extract a substring from a column
Definition: SqlUtil.qm.dox.h:2354
const JOP_RIGHT
for right outer joins
Definition: SqlUtil.qm.dox.h:3784
const OP_SUBSTR
the SQL "substr" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4341
*hash selectRow(*hash sh, *reference< string > sql, *hash opt)
returns a hash representing the row in the table that matches the argument hash; if more than one row...
int upsertCommit(hash row, int upsert_strategy=UpsertAuto, *hash opt)
update or insert the data in the table according to the hash argument; the table must have a unique k...
hash< ColumnOperatorInfo > cop_substr(auto column, int start, *int count)
returns a ColumnOperatorInfo hash for the "substr" operator with the given arguments; returns a subst...
const SZ_OPT
the data type takes an optional size parameter
Definition: SqlUtil.qm.dox.h:2216
hash< InsertOperatorInfo > iop_seq(string arg)
returns an InsertOperatorInfo hash for retrieving the value of the given sequence in insert queries ...
softint size
for data types requiring a size component, the size; for numeric columns this represents the precisio...
Definition: SqlUtil.qm.dox.h:2105
int update(hash set, hash cond, reference< string > sql, hash opt)
updates rows in the table matching an optional condition and returns the count of rows updated; no tr...
SQL operator info hash as returned by all operator functions.
Definition: SqlUtil.qm.dox.h:2123
number start
the starting number
Definition: SqlUtil.qm.dox.h:6075
const IOP_SEQ
for using the value of a sequence
Definition: SqlUtil.qm.dox.h:4805
the base abstract class for the database implementation
Definition: SqlUtil.qm.dox.h:6452
const COP_ROW_NUMBER
Analytic (window) function: ROW_NUMBER.
Definition: SqlUtil.qm.dox.h:2426
const DT_YEAR
Format unit: year.
Definition: SqlUtil.qm.dox.h:3503
*string index
the index supporting the constraint
Definition: SqlUtil.qm.dox.h:5879
represents a primary key
Definition: SqlUtil.qm.dox.h:5966
const JOP_INNER
for standard inner joins
Definition: SqlUtil.qm.dox.h:3774
const COP_LOWER
to return column value in lower case
Definition: SqlUtil.qm.dox.h:2259
hash< ColumnOperatorInfo > cop_prepend(auto column, string arg)
returns a ColumnOperatorInfo hash for the "prepend" operator with the given argument ...
*hash nest
option nested operation hash
Definition: SqlUtil.qm.dox.h:2145
const COP_DIVIDE
the SQL "divide" operator
Definition: SqlUtil.qm.dox.h:2309
string join(string str,...)
const DB_FUNCTIONS
Features constants.
Definition: SqlUtil.qm.dox.h:2166
const NUMERIC
specifies a numeric column (equivalent to Qore::Type::Number)
Definition: SqlUtil.qm.dox.h:2193
*hash sourceConstraints
a hash of ForeignConstraintSources, keyed by table name, the value is a hash of foreign constraints k...
Definition: SqlUtil.qm.dox.h:5876
*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...
string qore_type
a qore type string that will be converted to a native DB type with some default conversion ...
Definition: SqlUtil.qm.dox.h:2101
hash< UpdateOperatorInfo > make_uop(string uop, auto arg, *hash< UpdateOperatorInfo > nest)
returns an UpdateOperatorInfo hash
const DefaultOpMap
a hash of valid operators for use in Where Clauses
Definition: SqlUtil.qm.dox.h:4347
represents a unique column constraint
Definition: SqlUtil.qm.dox.h:5957
hash< OperatorInfo > op_ceq(string arg)
returns an OperatorInfo hash for the "=" operator with the given argument for use in where clauses wh...
abstract base class for constraints
Definition: SqlUtil.qm.dox.h:5776
const DT_SECOND
Format unit: hour.
Definition: SqlUtil.qm.dox.h:3518
constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:5734
const COP_APPEND
to append a string to a column on output
Definition: SqlUtil.qm.dox.h:2244