Qore SqlUtil Module Reference  1.2
SqlUtil.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file SqlUtil.qm Qore user module for working with SQL data
3 
4 /* SqlUtil.qm Copyright (C) 2013 - 2014 Qore Technologies, sro
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 // this module requires Qore 0.8.11 or better
26 
27 // requires the Util module
28 
29 // don't use "$" signs for variables and class members, assume local variable scope
30 
31 // require type definitions everywhere
32 
33 // enable all warnings
34 
35 
36 // version history is included below in the docs
37  ...
297  @endcode
298  @warning Oracle: using different comments in the same SQL can lead to new optimizer statement hard parsing.
299 
300  @anchor select_option_hint
301  @par Select Option "hint"
302  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).
303 
304  <b>Hint Example:</b>
305  @code
306 $table.selectRows( ("hint" : "full(t1)") );
307  @endcode
308  will produce select statement like this:
309  @code
310 select /*+ full(a) */ ...
311  @endcode
312  The string is taken as is and it's up to user to handle correct aliases in join functions etc.
313  @note Hints are platform dependent. Curently only Oracle and some versions of PostgreSQL hints are supported in Sqlutil module.
314  @warning Use hints only when you know what you are doing.
315 
316  @anchor select_option_columns
317  @par Select Option "columns"
318  <b>Columns Example:</b>
319  @code
320 my list $columns = ("id", "name", "started", cop_as("warnings", "warning_count"), cop_as("errors", "error_count"));
321 my *list $rows = $table.selectRows(("columns": $columns, "where": ("type": "user")));
322  @endcode
323  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
324  This option takes a list, each element of the list can be one of the following.\n\n
325  <b>A Simple String Giving a Column Name</b>\n
326  ex: \c "name"
327  @code
328 my *list $rows = $table.selectRows(("columns": ("id", "name", "started")));
329  @endcode \n
330  <b>A String in Dot Notation</b>\n
331  This format is for use with @ref select_option_join "joins"; ex: \c "q.name"
332  @code
333 my *list $rows = $table.selectRows(("columns": ("table.id", "t2.customer_name"), "join": join_inner($table2, "t2", ("id": "altid"))));
334  @endcode \n
335  <b>A Column Operation Specified by a Column Operator Function</b>\n
336  ex: <tt>cop_as("column_name", "column_alias")</tt> \n
337  See @ref sql_cop_funcs "column operator function" for more information on column operator functions
338  @code
339 my *list $rows = $table.selectRows(("columns": ("id", cop_as("warnings", "warning_count"), cop_as("errors", "error_count"))));
340  @endcode
341  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
342  <b>The Value \c "*", Meaning All Columns</b>\n
343  ex: \c "*"
344  @code
345 my *list $rows = $table.selectRows(("columns": "*"));
346  @endcode
347  This is the default if no \c "columns" key is included in the @ref select_option_hash "select option hash" \n\n
348  <b>An \c "*" in Dot Notation</b>\n
349  ex: \c "q.*"
350  @code
351 my *list $rows = $table.selectRows(("columns": ("table.id", "t2.*"), "join": join_inner($table2, "t2", ("id": "altid"))));
352  @endcode
353 
354  @anchor select_option_where
355  @par Select Option "where"
356  <b>Where Example:</b>
357  @code
358 my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
359  @endcode
360  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.
361 
362  @anchor select_option_orderby
363  @par Select Option "orderby"
364  <b>Orderby Example:</b>
365  @code
366 my *list $rows = $table.selectRows(("where": ("account_type": "CUSTOMER"), "orderby": "created_date"));
367  @endcode
368  This option is a list of the following values:
369  - a simple string giving a column name; ex: \c "name"
370  - 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"
371  @note
372  - By using the @ref select_option_offset "offset option" the results will be automatically ordered according to the primary key of the table
373 
374  @anchor select_option_desc
375  @par Select Option "desc"
376  <b>Desc Example:</b>
377  @code
378 my *list $rows = $table.selectRows(("where": ("account_type": "CUSTOMER"), "orderby": "created_date", "desc": True));
379  @endcode
380  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
381  Otherwise, ordered results are returned in ascending order by default.
382 
383  @anchor select_option_limit
384  @par Select Option "limit"
385  <b>Limit Example:</b>
386  @code
387 my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
388  @endcode
389  This option will limit the number of rows returned.
390  @note
391  - This option is required if the @ref select_option_offset "offset option" is non-zero
392  - 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
393 
394  @anchor select_option_offset
395  @par Select Option "offset"
396  <b>Offset Example:</b>
397  @code
398 my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
399  @endcode
400  This option specifies the row number offset for the rows returned where the first row is at offset zero.
401  @note
402  - 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.
403  - Additionally, this option requires the presence of the @ref select_option_limit "limit option", or an exception will be thrown.
404  @see @ref sql_paging
405 
406  @anchor select_option_join
407  @par Select Option "join"
408  <b>Join Example:</b>
409  @code
410 my *list $rows = $table.selectRows(("columns": ("name", "version", "id", cop_as("st.value", "source"), cop_as("st.value", "offset")),
411  "join": join_left($function_instance_tags, "st", NOTHING, ("st.tag": "_source"))
412  + join_left($function_instance_tags, "lt", NOTHING, ("st.tag": "_offset"))));
413  @endcode
414  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).
415  @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
416 
417  @see @ref joins for more examples
418 
419  @anchor select_option_groupby
420  @par Select Option "groupby"
421  <b>Groupby Example:</b>
422  @code
423 my *list $rows = $table.selectRows(("columns": (cop_as(cop_max("service_type"), "type"), cop_count()), "groupby": "service_type"));
424  @endcode
425  The \c "groupby" option allows for aggregate SQL column operator functions to be used (ex: @ref cop_max(), cop_min()) in select statements.
426  The \c "groupby" hash key should be assigned to a list of column specifiers or a single column specifier. Column specifies for the \c "groupby"
427  key are strings giving column names, optionally in dot notation.
428 
429  @anchor select_option_having
430  @par Select Option "having"
431  <b>Having Example:</b>
432  @code
433 my *list $rows = $table.selectRows(("columns": (cop_as(cop_max("service_type"), "type"), cop_count()), "groupby": "service_type", "having": ("service_type": (COP_COUNT, op_ge(100)))));
434  @endcode
435  The \c "having" option allows for query results with aggregate SQL column operator functions to be filtered by user-defined criteria.
436  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.
437 
438  @anchor select_option_superquery
439  @par Select Option "superquery"
440  <b>Superquery Example:</b>
441  @code
442 my *list $rows = $table.selectRows("columns": ("serviceid", "service_methodid", cop_as(cop_over(cop_max("service_methodid"), "serviceid"), "max_methodid")), "superquery": ("columns": ("serviceid", "service_methodid"), "where": ("max_methodid": op_ceq("service_methodid"))));
443  @endcode
444  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
445  The above example results in an SQL command equivalent to the following:
446  @code
447 my *list $rows = $table.vselectRows("select serviceid,service_methodid from (select serviceid,service_methodid,max(service_methodid) over (partition by serviceid) as max_methodid from schema.service_methods) subquery where max_methodid = service_methodid");
448  @endcode
449  @note that MySQL does not support SQL windowing functions so the above example would fail on MySQL.
450 
451  @anchor select_option_forupdate
452  @par Select Option "forupdate"
453  <b>For Update Example:</b>
454  @code
455 on_success $ds.commit();
456 on_error $ds.rollback();
457 
458 my *list $rows = $table.selectRows("columns": ("serviceid", "service_methodid"), "forupdate": True);
459  @endcode
460  \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.
461  The above example results in an SQL commit equivalent to the following:
462  @code
463 my *list $rows = $table.vselectRows("select serviceid,service_methodid from schema.service_methods for update");
464  @endcode
465 
466  @subsection sql_paging Select With Paging
467 
468  There is support for paging query results in the following methods:
469  - @ref SqlUtil::Table::getRowIterator()
470  - @ref SqlUtil::Table::getSelectSql()
471  - @ref SqlUtil::Table::select()
472  - @ref SqlUtil::Table::selectRows()
473 
474  @note the above list also applies to the corresponding @ref SqlUtil::AbstractTable methods
475 
476  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.
477 
478  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.
479 
480  @par Example:
481  Select 100 rows starting at row 200 (the table's primary key will be used for the \c "orderby" option by default): \n
482  @code
483 my *list $rows = $table.selectRows(("where": ("type": "user"), "limit": 100, "offset": 200));
484  @endcode
485  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:
486  @code
487 $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));
488  @endcode
489  And for PostgreSQL:
490  @code
491 $ds.vselectRows("select * from public.table where type = %v order by type limit %v offset %v", ("user", 100, 200));
492  @endcode
493 
494  @subsection check_matching_rows Check For At Least One Matching Row
495 
496  Use the @ref SqlUtil::Table::findSingle() method to find at least one matching row:
497  @code
498 my *hash $h = $table.findSingle(("account_type": "CUSTOMER"));
499 if ($h)
500  printf("found 1 customer row: %y\n", $l[0]);
501  @endcode
502 
503  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):
504  @code
505 my *hash $h = $table.selectRow(("where": ("account_type": "CUSTOMER"), "limit": 1));
506 if ($h)
507  printf("found 1 customer row: %y\n", $l[0]);
508  @endcode
509 
510  @section inserting_data Inserting Data into the Database
511 
512  The following methods can be used to insert data into the database:
513  - @ref SqlUtil::Table::insert(): inserts a single row into a table and commits the transaction
514  - @ref SqlUtil::Table::insertNoCommit(): inserts a single row into a table without committing the transaction
515  - @ref SqlUtil::Table::insertFromSelect(): inserts data in a table based on a select statement created from the @ref select_option_hash "select option hash" argument and commits the transaction
516  - @ref SqlUtil::Table::insertFromSelectNoCommit(): inserts data in a table based on a select statement created from the @ref select_option_hash "select option hash" argument and without committing the transaction
517 
518  @see @ref sql_upsert for information about upserting or merging data
519 
520  @subsection inserting_data_explicitly Inserting Data Explicitly
521 
522  @par Example:
523  @code
524 $table.insert(("id": $id, "name": $name, "created": now_us()));
525  @endcode
526 
527  Data can be explicitly inserted into the database with immediate values with @ref SqlUtil::Table::insert() and @ref SqlUtil::Table::insertNoCommit() as in the above example.
528 
529  @subsection inserting_data_from_select Inserting Data From a Select Statement
530 
531  @par Example:
532  @code
533 my int $rows = $table.insertFromSelect(("id", "name", "created"), $source_table, (("columns": ("cid", "fullname", "created"), "where": ("type": "CUSTOMER"))));
534  @endcode
535 
536  Data can be inserted into the database based on the results of a select statement with @ref SqlUtil::Table::insertFromSelect() and @ref SqlUtil::Table::insertFromSelectNoCommit() as in the above example.
537 
538  The example above would generate a %Qore SQL command like the following:
539  @code
540 return $ds.vexec("insert into schema.table (id,name,created) select cid,fullname,created from schema.source_table where type = %v", ("CUSTOMER"));
541  @endcode
542 
543  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.
544 
545  @subsection inserting_data_from_iterator Inserting Data from an Iterator Source
546 
547  To insert data from an iterator source (such as an @ref Qore::SQL::SQLStatement object), call @ref SqlUtil::Table::insertFromIterator() or @ref SqlUtil::Table::insertFromIteratorNoCommit() as in the following example:
548 
549  @par Example:
550  @code
551 # get the rows to be inserted
552 my list $l = get_table_rows();
553 # insert the data and commit after every 5000 rows
554 $table.insertFromIterator($l.iterator(), ("commit_block": 5000));
555  @endcode
556 
557  The iterator given to the @ref SqlUtil::Table::insertFromIterator() or @ref SqlUtil::Table::insertFromIteratorNoCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "hash".
558 
559  @note the @ref SqlUtil::AbstractTable::InsertOptions "insert option" \c "commit_block" can be used to insert a large amount of data in pieces in order to avoid overwhelming the database server's rollback cache
560 
561  @section updating_data Updating Data
562 
563  The following methods can be used to update data:
564  - @ref SqlUtil::Table::update(): updates a single row and commits the transaction
565  - @ref SqlUtil::Table::updateNoCommit(): updates a single row and does not commit the transaction
566 
567  @par Example:
568  @code
569 my int $rows_updated = t.update(("permission_type": uop_append("-migrated", uop_lower())));
570  @endcode
571 
572  The example above generates a %Qore SQL command like the following on Oracle and PostgreSQL for example:
573  @code
574 return $ds.vexec("update schema.table set permission_type = lower(permission_type) || '-migrated');
575  @endcode
576  And the following on MySQL:
577  @code
578 return $ds.vexec("update schema.table set permission_type = concat(lower(permission_type), '-migrated'));
579  @endcode
580 
581  @section deleting_data Deleting Data
582 
583  The following methods can be used to dekete data:
584  - @ref SqlUtil::Table::del(): updates the table based on a @ref where_clauses "where clause" and commits the transaction
585  - @ref SqlUtil::Table::delNoCommit(): updates the table based on a @ref where_clauses "where clause" and does not commit the transaction
586  - @ref SqlUtil::Table::truncate(): truncates the table and commits the transaction releasing the transaction lock on the underlying datasource object
587  - @ref SqlUtil::Table::truncateNoCommit(): truncates the table and does not commit the transaction
588 
589  @par Example:
590  @code
591 my int $dcnt = $table.del(("record_type": "OLD-CUSTOMER"));
592  @endcode
593 
594  The above example would generate a %Qore SQL command like the following:
595  @code
596 return $ds.vexec("delete from schema.table where record_type = %v", ("OLD-CUSTOMER"));
597  @endcode
598 
599  The @ref SqlUtil::Table::del() and @ref SqlUtil::Table::delNoCommit() methods can be used to delete data from the database.
600 
601  See @ref where_clauses for information about specifying the criteria for the rows to be deleted.
602 
603  @section joins Joining Tables
604 
605  Joining tables is made by providing a join specification to the @ref select_option_join "join select option" in
606  a @ref select_option_hash "select option hash" as in the following example:
607  @code
608 my *list $rows = $table.selectRows(("columns": ("table.id", "t2.customer_name"), "join": join_inner($table2, "t2", ("id": "altid"))));
609  @endcode
610  In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt>.
611 
612  Joins on multiple tables are performed by combining the results of @ref sql_op_funcs "join functions" with the @ref plus_operator "+ operator"
613  as follows:
614  @code
615 my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner($table3, "t3")));
616  @endcode
617  In the above example, \a table is joined with \a table2 on <tt>table.id = table2.altid</tt> and with \a table3 on an
618  automatically detected primary key to foreign key relationship between the two tables.
619 
620  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
621  argument to the @ref sql_op_funcs "join function" as in the following example:
622  @code
623 my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid")) + join_inner("t2", $table3, "t3")));
624  @endcode
625  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
626  with \a table3 (aliased as \c t3) on an automatically detected primary key to foreign key relationship between the two tables.
627 
628  @see @ref select_option_join "join select option"
629 
630  @section where_clauses Where Clauses
631 
632  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:
633  - @ref SqlUtil::Table::del()
634  - @ref SqlUtil::Table::delNoCommit()
635  - @ref SqlUtil::Table::findAll()
636  - @ref SqlUtil::Table::findSingle()
637  - @ref SqlUtil::Table::getRowIterator()
638  - @ref SqlUtil::Table::getSelectSql()
639  - @ref SqlUtil::Table::insertFromSelect()
640  - @ref SqlUtil::Table::insertFromSelectNoCommit()
641  - @ref SqlUtil::Table::select()
642  - @ref SqlUtil::Table::selectRow()
643  - @ref SqlUtil::Table::selectRows()
644  - @ref SqlUtil::Table::update()
645  - @ref SqlUtil::Table::updateNoCommit()
646  - @ref SqlUtil::Table::upsertFromSelect()
647  - @ref SqlUtil::Table::upsertFromSelectNoCommit()
648 
649  @note the above list also applies to the corresponding @ref SqlUtil::AbstractTable methods
650 
651  The where clause or condition hash is made of keys signifying the column names, and either a direct value meaning that the column value has to match exactly, or SQL operators can be given by using the appropriate operator function as the key value. Each member of the where hash translates to an expression that is combined with \c "AND" in the SQL query; to combine expressions with \c "OR", then use a list of @ref select_option_hash "select option hashes", which will combine each @ref select_option_hash "select option hash" with \c "OR" as in @ref where_list "this example".
652 
653  The where condition hash has the following format:
654  - each key gives a column name or a table/alias with column name in dot notation
655  - 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
656 
657  @note To reference a column more than once in a where clause, prefix the column specification with a unique number and a colon as in the following example: @code my hash $w = ("0:created": op_ge($mindate), "1:created": op_lt($maxdate)); @endcode
658 
659  See @ref sql_op_funcs for a list of operator functions.
660 
661  @par Where Hash Example:
662  @code
663 my hash $w = (
664  "name": "Smith",
665  "account_type": op_like("%CUSTOMER%"),
666  "id": op_ge(500),
667 );
668  @endcode \n
669  The preceding example results in a where clause equivalent to: \c "name = 'Smith' and type like '%CUSTOMER%' and id >= 500", except
670  that bind by value is used, so, if used in a context like the following:
671  @code
672 my Table $t($ds, "table");
673 my *hash $qh = $t.select(("where": $w));
674  @endcode \n
675  the complete query would look instead as follows:
676  @code
677 $ds.vselect("select * from table where name = %v and account_type like %v and id >= %v", ("Smith", "%CUSTOMER%", 500));
678  @endcode
679 
680  @anchor where_list
681  @par Where List Example:
682  @code
683 my hash $w1 = (
684  "name": "Smith",
685  "account_type": op_like("%CUSTOMER%"),
686  "id": op_ge(500),
687 );
688 my hash $w2 = (
689  "name": "Jones",
690  "account_type": op_like("%VENDOR%"),
691  "id": op_ge(2500),
692 );
693 my Table $t($ds, "table");
694 my *hash $qh = $t.select(("where": ($w1, $w2)));
695  @endcode \n
696  the complete query would look instead as follows:
697  @code
698 $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));
699  @endcode
700 
701  @par Code Examples:
702  Find a single row in the table where the \c "permission_type" column is a value between \c "US" and \c "UX":\n
703  @code
704 my *hash $row = $table.findSingle(("permission_type": op_between("US", "UX")));
705  @endcode
706  resulting in an internal SQL command that looks as follows (depending on the database):
707  @code
708 my *hash $row = $ds.vselectRow("select * from table where permission_type between %v and %v limit %v", ("US", "UX", 1));
709  @endcode \n
710  Delete all rows in the table where the \c "name" column is like \c "%Smith%":\n
711  @code
712 my int $row_count = $table.del(("name": op_like("%Smith%")));
713  @endcode
714  resulting in an internal SQL command that looks as follows:
715  @code
716 $ds.vexec("delete from table where name like %v", ("%Smith%"));
717  @endcode \n
718  Find all rows where \c "id" is greater than \c 100 and \c "created" is after \c 2013-03-01:\n
719  @code
720 my *list $rows = $table.findAll(("id": op_gt(100), "created": op_gt(2013-03-01)));
721  @endcode
722  resulting in an internal SQL command that looks as follows:
723  @code
724 $ds.vexec("select * from table where id > %v and created > %v", (100, 2013-03-01));
725  @endcode \n
726 
727  @section sql_upsert Upserting or Merging Data
728 
729  This module offers a high-level api for "upserting" or merging data from one table into another table through the following methods:
730  - @ref SqlUtil::Table::upsert()
731  - @ref SqlUtil::Table::upsertNoCommit()
732  - @ref SqlUtil::Table::getUpsertClosure()
733  - @ref SqlUtil::Table::getUpsertClosureWithValidation()
734  - @ref SqlUtil::Table::upsertFromIterator()
735  - @ref SqlUtil::Table::upsertFromIteratorNoCommit()
736  - @ref SqlUtil::Table::upsertFromSelect()
737  - @ref SqlUtil::Table::upsertFromSelectNoCommit()
738 
739  @subsection sql_upsert_single Upsert a Single Row
740 
741  @par Example:
742  @code
743 $table.upsert(("id": $id, "name": $name, "account_type": $account_type));
744  @endcode
745 
746  To upsert or merge a single row in the database, call @ref SqlUtil::Table::upsert() or @ref SqlUtil::Table::upsertNoCommit() with the
747  single row to be upserted or merged as a hash as in the preceding example.
748 
749  @subsection sql_upsert_many Upserting Many Rows Using An Upsert Closure
750 
751  To upsert or merge many rows by using an upsert closure, call @ref SqlUtil::Table::getUpsertClosure() or @ref SqlUtil::Table::getUpsertClosureWithValidation() and provide an example row as an argument to acquire a closure that will be executed on the rest of the rows as in the following example.
752 
753  @par Simple Example:
754  @code
755 # get the rows to be inserted
756 my list $l = get_table_rows();
757 
758 if ($l) {
759  my code $upsert = $table.getUpsertClosure($l[0]);
760 
761  on_success $ds.commit();
762  on_error $ds.rollback();
763 
764  # loop through the reference data rows
765  map $upsert($1), $l;
766 }
767  @endcode
768 
769  @par Complex Example With Callbacks:
770  @code
771 # set the upsert strategy depending on the use case
772 my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
773 
774 # hash summarizing changes
775 my hash $sh;
776 
777 # get the rows to be inserted
778 my list $l = get_table_rows();
779 
780 if ($l) {
781  # get the upsert closure to use based on the first row to be inserted
782  my code $upsert = $table.getUpsertClosure($l[0], $upsert_strategy);
783 
784  on_success $ds.commit();
785  on_error $ds.rollback();
786 
787  # loop through the reference data rows
788  foreach my hash $h in ($l) {
789  my int $code = $upsert($h);
790  if ($code == AbstractTable::UR_Unchanged)
791  continue;
792 
793  my string $change = AbstractTable::UpsertResultMap{$code};
794  ++$sh{$change};
795 
796  if (!$verbose) {
797  printf(".");
798  flush();
799  }
800  else if ($verbose > 1)
801  printf("*** reference data %s: %y: %s\n", $table.getName(), $h, $change);
802  }
803 
804  # show table summary
805  if ($sh)
806  printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
807  else
808  printf("*** reference data %s: OK\n", $table.getName());
809 }
810  @endcode
811 
812  @subsection sql_upsert_from_iterator Upserting Many Rows from an Iterator Source
813 
814  To upsert or merge many rows from an iterator source (such as an @ref Qore::SQL::SQLStatement object), call @ref SqlUtil::Table::upsertFromIterator() or @ref SqlUtil::Table::upsertFromIteratorNoCommit() as in the following example:
815 
816  @par Simple Example:
817  @code
818 # get the rows to be inserted
819 my list $l = get_table_rows();
820 $table.upsertFromIterator($l.iterator());
821  @endcode
822 
823  @par Complex Example With Callbacks:
824  @code
825 # set the upsert strategy depending on the use case
826 my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
827 
828 # get the rows to be inserted
829 my list $l = get_table_rows();
830 
831 my code $callback = sub (string $table_name, hash $row, int $result) {
832  if ($result == AbstractTable::UR_Unchanged)
833  return;
834  my string $change = AbstractTable::UpsertResultMap{$result};
835  if ($verbose)
836  printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
837 };
838 
839 my hash $sh = $table.upsertFromIterator($l.iterator(), $upsert_strategy, False, ("info_callback": $callback, "commit_block": 5000));
840 if ($sh)
841  printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
842 else
843  printf("*** reference data %s: OK\n", $table.getName());
844  @endcode
845 
846  The iterator given to the @ref SqlUtil::Table::upsertFromIterator() or @ref SqlUtil::Table::upsertFromIteratorNoCommit() methods can be any iterator whose @ref Qore::AbstractIterator::getValue() "getValue()" method returns a @ref hash_type "hash".
847 
848  @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
849 
850  @subsection sql_upsert_from_select Upserting Many Rows from a Select Statement
851 
852  To upsert or merge many rows from a select statement, use @ref SqlUtil::Table::upsertFromSelect() or @ref SqlUtil::Table::upsertFromSelectNoCommit() as in the following example:
853 
854  @par Simple Example:
855  @code
856 $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")));
857  @endcode
858 
859  @par Complex Example With Callbacks:
860  @code
861 # set the upsert strategy depending on the use case
862 my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
863 
864 my code $callback = sub (string $table_name, hash $row, int $result) {
865  if ($result == AbstractTable::UR_Unchanged)
866  return;
867  my string $change = AbstractTable::UpsertResultMap{$result};
868  if ($verbose)
869  printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
870 };
871 
872 my hash $sh = $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), $upsert_strategy, False, ("info_callback": $callback, "commit_block": 5000));
873 if ($sh)
874  printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
875 else
876  printf("*** reference data %s: OK\n", $table.getName());
877  @endcode
878 
879  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).
880 
881  @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
882 
883  @subsection sql_upsert_with_delete Upserting Many Rows and Deleting Unwanted Rows
884 
885  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.
886 
887  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.
888 
889  @par Simple Example:
890  @code
891 # get the rows to be inserted
892 my list $l = get_table_rows();
893 $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), AbstractTable::UpsertAuto, ("delete_others": True, "commit_block": 5000));
894  @endcode
895 
896  @par Complex Example With Callbacks:
897  @code
898 # set the upsert strategy depending on the use case
899 my int $upsert_strategy = $verbose ? AbstractTable::UpsertSelectFirst : AbstractTable::UpsertAuto;
900 
901 # get the rows to be inserted
902 my list $l = get_table_rows();
903 
904 my code $callback = sub (string $table_name, hash $row, int $result) {
905  if ($result == AbstractTable::UR_Unchanged)
906  return;
907  my string $change = AbstractTable::UpsertResultMap{$result};
908  if ($verbose)
909  printf("*** reference data %s: %y: %s\n", $table_name, $row, $change);
910 };
911 
912 my hash $sh = $table.upsertFromSelect($table2, ("where": ("account_type": "CUSTOMER")), $upsert_strategy, ("delete_others": True, "info_callback": $callback, "commit_block": 5000));
913 if ($sh)
914  printf("*** reference data %s: %s\n", $table.getName(), (foldl $1 + ", " + $2, (map sprintf("%s: %d", $1.key, $1.value), $sh.pairIterator())));
915 else
916  printf("*** reference data %s: OK\n", $table.getName());
917  @endcode
918 
919  @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
920 
921  @subsection sql_upsert_strategies Upsert Strategies
922  The approach used is based on one of the following strategies (see @ref upsert_options):
923  - @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
924  - @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
925  - @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
926  - @ref SqlUtil::AbstractTable::UpsertSelectFirst "AbstractTable::UpsertSelectFirst": first a select is made on the unique key, if the data to be updated is equal, nothing is done and @ref upsert_results "upsert result" @ref SqlUtil::AbstractTable::UR_Unchanged is returned
927  - @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
928 
929  @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.
930 */
1610 namespace SqlUtil {
1612 
1613  /* @defgroup DBFeaturesConstants DB Features Constants
1614  These constants can be used as a lookup values in AbstractDatabase::features() method.
1615  */
1617 
1620  const DB_FUNCTIONS = "functions";
1622  const DB_MVIEWS = "materialized views";
1624  const DB_PACKAGES = "packages";
1626  const DB_PROCEDURES = "procedures";
1628  const DB_SEQUENCES = "sequences";
1630  const DB_TABLES = "tables";
1632  const DB_TYPES = "named types";
1634  const DB_VIEWS = "views";
1636 
1637  /* @defgroup SqlTypeConstants SQL Type Constants
1638  These constants can be used for the \c "qore_type" values when creating columns to specify additional SQL column types
1639  */
1641  const VARCHAR = "string";
1643 
1645  const NUMERIC = "number";
1646 
1648  const CHAR = "char";
1649 
1651  const BLOB = "blob";
1652 
1654  const CLOB = "clob";
1656 
1661  const SZ_NONE = 0;
1663 
1665  const SZ_MAND = 1;
1666 
1668  const SZ_OPT = 2;
1669 
1671  const SZ_NUM = 3;
1673 
1678 
1681  const COP_AS = "as";
1682 
1684 
1686  const COP_PREPEND = "prepend";
1687 
1689 
1691  const COP_APPEND = "append";
1692 
1694 
1696  const COP_VALUE = "value";
1697 
1699 
1701  const COP_UPPER = "upper";
1702 
1704 
1706  const COP_LOWER = "lower";
1707 
1709 
1711  const COP_DISTINCT = "distinct";
1712 
1714 
1716  const COP_MIN = "min";
1717 
1719 
1721  const COP_MAX = "max";
1722 
1724 
1726  const COP_AVG = "avg";
1727 
1729 
1731  const COP_COUNT = "count";
1732 
1734 
1736  const COP_OVER = "over";
1737 
1739 
1741  const COP_MINUS = "minus";
1742 
1744 
1746  const COP_PLUS = "plus";
1747 
1749 
1751  const COP_DIVIDE = "divide";
1752 
1754 
1756  const COP_MULTIPLY = "multiply";
1757 
1759 
1761  const COP_YEAR = "year";
1762 
1764 
1766  const COP_YEAR_MONTH = "year_month";
1767 
1769 
1771  const COP_YEAR_DAY = "year_day";
1772 
1774 
1776  const COP_YEAR_HOUR = "year_hour";
1777 
1779 
1781  const COP_SEQ = "seq";
1782 
1784  const DefaultCopMap = (
1785  COP_AS: (
1786  "arg": Type::String,
1787  "code": string (string cve, string arg) {
1788  return sprintf("%s as %s", cve, arg);
1789  },
1790  ),
1791  COP_PREPEND: (
1792  "arg": Type::String,
1793  "sqlvalue": True,
1794  "code": string (string cve, string arg) {
1795  return sprintf("%s||%s", arg, cve);
1796  },
1797  ),
1798  COP_APPEND: (
1799  "arg": Type::String,
1800  "sqlvalue": True,
1801  "code": string (string cve, string arg) {
1802  return sprintf("%s||%s", cve, arg);
1803  },
1804  ),
1805  COP_VALUE: (
1806  "sqlvalue": True,
1807  "nocolumn": True,
1808  "code": string (*string cve, any arg) {
1809  return arg;
1810  },
1811  ),
1812  COP_UPPER: (
1813  "code": string (string cve, any arg) {
1814  return sprintf("upper(%s)", cve);
1815  },
1816  ),
1817  COP_LOWER: (
1818  "code": string (string cve, any arg) {
1819  return sprintf("lower(%s)", cve);
1820  },
1821  ),
1822  COP_DISTINCT: (
1823  "code": string (string cve, any arg) {
1824  return sprintf("distinct %s", cve);
1825  },
1826  ),
1827  COP_MIN: (
1828  "code": string (string cve, any arg) {
1829  return sprintf("min(%s)", cve);
1830  },
1831  "group": True,
1832  ),
1833  COP_MAX: (
1834  "code": string (string cve, any arg) {
1835  return sprintf("max(%s)", cve);
1836  },
1837  "group": True,
1838  ),
1839  COP_AVG: (
1840  "code": string (string cve, any arg) {
1841  return sprintf("avg(%s)", cve);
1842  },
1843  "group": True,
1844  ),
1845  COP_COUNT: (
1846  "nocolumn": True,
1847  "code": string (*string cve, any arg) {
1848  return sprintf("count(%s)", cve ? cve : "1");
1849  },
1850  ),
1851  COP_MINUS: (
1852  "argcolumn": True,
1853  "code": string (string arg1, string arg2) {
1854  return sprintf("%s - %s", arg1, arg2);
1855  },
1856  ),
1857  COP_PLUS: (
1858  "argcolumn": True,
1859  "code": string (string arg1, string arg2) {
1860  return sprintf("%s + %s", arg1, arg2);
1861  },
1862  ),
1863  COP_DIVIDE: (
1864  "argcolumn": True,
1865  "code": string (string arg1, string arg2) {
1866  return sprintf("%s / %s", arg1, arg2);
1867  },
1868  ),
1869  COP_MULTIPLY: (
1870  "argcolumn": True,
1871  "code": string (string arg1, string arg2) {
1872  return sprintf("%s * %s", arg1, arg2);
1873  },
1874  ),
1875  );
1877 
1894 
1903  hash make_cop(string cop, any column, any arg);
1904 
1905 
1907 
1917  hash cop_as(any column, string arg);
1918 
1919 
1921 
1931  hash cop_prepend(any column, string arg);
1932 
1933 
1935 
1945  hash cop_append(any column, string arg);
1946 
1947 
1949 
1958  hash cop_value(any arg);
1959 
1960 
1962 
1971  hash cop_upper(any column);
1972 
1973 
1975 
1984  hash cop_lower(any column);
1985 
1986 
1988 
1997  hash cop_distinct(any column);
1998 
1999 
2001 
2010  hash cop_min(any column);
2011 
2012 
2014 
2023  hash cop_max(any column);
2024 
2025 
2027 
2036  hash cop_avg(any column);
2037 
2038 
2040 
2047  hash cop_count(string column = "");
2048 
2049 
2051 
2058  hash cop_over(any column, string arg);
2059 
2060 
2062 
2073  hash cop_minus(any column1, any column2);
2074 
2075 
2077 
2088  hash cop_plus(any column1, any column2);
2089 
2090 
2092 
2103  hash cop_divide(any column1, any column2);
2104 
2105 
2107 
2118  hash cop_multiply(any column1, any column2);
2119 
2120 
2122 
2131  hash cop_year(any column);
2132 
2133 
2135 
2144  hash cop_year_month(any column);
2145 
2146 
2148 
2157  hash cop_year_day(any column);
2158 
2159 
2161 
2170  hash cop_year_hour(any column);
2171 
2172 
2174 
2183  hash cop_seq(string seq);
2184 
2186 
2190  const DefaultUopMap = (
2192  COP_PREPEND: True,
2193  COP_APPEND: True,
2194  COP_UPPER: True,
2195  COP_LOWER: True,
2196  COP_SEQ: True,
2197  );
2199 
2215 
2224  hash make_uop(string uop, any arg, *hash nest);
2225 
2226 
2228 
2238  hash uop_prepend(string arg, *hash nest);
2239 
2240 
2242 
2252  hash uop_append(string arg, *hash nest);
2253 
2254 
2256 
2265  hash uop_upper(*hash nest);
2266 
2267 
2269 
2278  hash uop_lower(*hash nest);
2279 
2280 
2282 
2291  hash uop_seq(string seq);
2292 
2294 
2301 
2304  const JOP_INNER = "inner";
2305 
2307 
2309  const JOP_LEFT = "left";
2310 
2312 
2314  const JOP_RIGHT = "right";
2315 
2317  const JopMap = (
2318  JOP_INNER: "inner",
2319  JOP_LEFT: "left outer",
2320  JOP_RIGHT: "right outer",
2321  );
2323 
2333 
2337  hash make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt);
2338 
2339 
2341 
2360  hash join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2361 
2362 
2364 
2383  hash join_inner(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2384 
2385 
2387 
2407  hash join_inner(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2408 
2409 
2411 
2431  hash join_inner(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2432 
2433 
2435 
2454  hash join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2455 
2456 
2458 
2477  hash join_left(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2478 
2479 
2481 
2501  hash join_left(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2502 
2503 
2505 
2525  hash join_left(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2526 
2527 
2529 
2548  hash join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2549 
2550 
2552 
2571  hash join_right(Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2572 
2573 
2575 
2595  hash join_right(string ta, AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt);
2596 
2597 
2599 
2619  hash join_right(string ta, Table table, *string alias, *hash jcols, *hash cond, *hash opt);
2620 
2622 
2627 
2630  const OP_LIKE = "like";
2631 
2633 
2635  const OP_LT = "<";
2636 
2638 
2640  const OP_LE = "<=";
2641 
2643 
2645  const OP_GT = ">";
2646 
2648 
2650  const OP_GE = ">=";
2651 
2653 
2655  const OP_NE = "!=";
2656 
2658 
2660  const OP_EQ = "=";
2661 
2663 
2665  const OP_CLT = "C<";
2666 
2668 
2670  const OP_CLE = "C<=";
2671 
2673 
2675  const OP_CGT = "C>";
2676 
2678 
2680  const OP_CGE = "C>=";
2681 
2683 
2685  const OP_CNE = "C!=";
2686 
2688 
2690  const OP_CEQ = "C=";
2691 
2693 
2695  const OP_BETWEEN = "between";
2696 
2698 
2700  const OP_IN = "in";
2701 
2703 
2705  const OP_NOT = "not";
2706 
2708  const DefaultOpMap = (
2709  OP_LIKE: (
2710  "code": string (object t, string cn, any arg, reference args) {
2711  args += arg;
2712  return sprintf("%s like %v", cn);
2713  },
2714  ),
2715  OP_LT: (
2716  "code": string (object t, string cn, any arg, reference args) {
2717  args += arg;
2718  return sprintf("%s < %v", cn);
2719  },
2720  ),
2721  OP_LE: (
2722  "code": string (object t, string cn, any arg, reference args) {
2723  args += arg;
2724  return sprintf("%s <= %v", cn);
2725  },
2726  ),
2727  OP_GT: (
2728  "code": string (object t, string cn, any arg, reference args) {
2729  args += arg;
2730  return sprintf("%s > %v", cn);
2731  },
2732  ),
2733  OP_GE: (
2734  "code": string (object t, string cn, any arg, reference args) {
2735  args += arg;
2736  return sprintf("%s >= %v", cn);
2737  },
2738  ),
2739  OP_NE: (
2740  "code": string (object t, string cn, any arg, reference args) {
2741  if (arg === NULL || !exists arg)
2742  return sprintf("%s is not null", cn);
2743  args += arg;
2744  return sprintf("%s != %v", cn);
2745  },
2746  ),
2747  OP_EQ: (
2748  "code": string (object t, string cn, any arg, reference args) {
2749  if (arg === NULL || !exists arg)
2750  return sprintf("%s is null", cn);
2751  args += arg;
2752  return sprintf("%s = %v", cn);
2753  },
2754  ),
2755  OP_BETWEEN: (
2756  "code": string (object t, string cn, any arg, reference args) {
2757  args += arg[0];
2758  args += arg[1];
2759  return sprintf("%s between %v and %v", cn);
2760  },
2761  ),
2762  OP_IN: (
2763  "code": string (object t, string cn, any arg, reference args) {
2764  *string ins = (foldl $1 + "," + $2, (map t.getSqlValue($1), arg));
2765  return ins ? sprintf("%s in (%s)", cn, ins) : "1 != 1";
2766  },
2767  ),
2768  OP_NOT: (
2769  "recursive": True,
2770  "code": string (object t, string cn, any arg, reference args) {
2771  return sprintf("not (%s)", cn);
2772  },
2773  ),
2774  OP_CLT: (
2775  "argcolumn": True,
2776  "code": string (object t, string cn, any arg, reference args) {
2777  return sprintf("%s < %s", cn, arg);
2778  },
2779  ),
2780  OP_CLE: (
2781  "argcolumn": True,
2782  "code": string (object t, string cn, any arg, reference args) {
2783  return sprintf("%s <= %s", cn, arg);
2784  },
2785  ),
2786  OP_CGT: (
2787  "argcolumn": True,
2788  "code": string (object t, string cn, any arg, reference args) {
2789  return sprintf("%s > %s", cn, arg);
2790  },
2791  ),
2792  OP_CGE: (
2793  "argcolumn": True,
2794  "code": string (object t, string cn, any arg, reference args) {
2795  return sprintf("%s >= %s", cn, arg);
2796  },
2797  ),
2798  OP_CNE: (
2799  "argcolumn": True,
2800  "code": string (object t, string cn, any arg, reference args) {
2801  return sprintf("%s != %s", cn, arg);
2802  },
2803  ),
2804  OP_CEQ: (
2805  "argcolumn": True,
2806  "code": string (object t, string cn, string arg, reference args) {
2807  return sprintf("%s = %s", cn, arg);
2808  },
2809  ),
2810  );
2812 
2833  hash make_op(string op, any arg);
2835 
2836 
2838 
2847  hash op_like(string str);
2848 
2849 
2851 
2862  hash op_lt(any arg);
2863 
2864 
2866 
2877  hash op_le(any arg);
2878 
2879 
2881 
2892  hash op_gt(any arg);
2893 
2894 
2896 
2907  hash op_ge(any arg);
2908 
2909 
2911 
2922  hash op_ne(any arg);
2923 
2924 
2926 
2937  hash op_eq(any arg);
2938 
2939 
2941 
2953  hash op_between(any l, any r);
2954 
2955 
2957 
2964  hash op_in();
2965 
2966 
2968 
2977  hash op_in(list args);
2978 
2979 
2981 
2988  hash op_not(hash arg);
2989 
2990 
2992 
3003  hash op_clt(string arg);
3004 
3005 
3007 
3018  hash op_cle(string arg);
3019 
3020 
3022 
3033  hash op_cgt(string arg);
3034 
3035 
3037 
3048  hash op_cge(string arg);
3049 
3050 
3052 
3063  hash op_cne(string arg);
3064 
3065 
3067 
3078  hash op_ceq(string arg);
3079 
3081 
3088 
3091  const IOP_SEQ = "seq";
3092 
3094  const DefaultIopMap = hash();
3096 
3102 
3110  hash make_iop(string iop, any arg);
3111 
3112 
3114 
3123  hash iop_seq(string arg);
3124 
3126 
3129 
3130 public:
3131 private:
3132 
3133 public:
3134 
3135  private :
3136  *hash h;
3137 
3138 public:
3139 
3141  constructor(*hash nh);
3142 
3143 
3146 
3147 
3149 
3164  any memberGate(string k);
3165 
3166 
3168 
3174  clear();
3175 
3176 
3178  abstract any take(string k);
3179 
3181  renameKey(string old_name, string new_name);
3182 
3183 
3185  *hash getHash();
3186 
3187 
3189 
3198  bool matchKeys(hash h1);
3199 
3200 
3202 
3211  bool matchKeys(list l);
3212 
3213 
3215 
3225 
3226 
3228 
3237  bool partialMatchKeys(hash h1);
3238 
3239 
3241 
3250  bool partialMatchKeys(list l);
3251 
3252 
3254 
3264 
3265 
3267 
3276  bool val();
3277 
3278 
3280 
3287  list keys();
3288 
3289 
3291 
3298  list values();
3299 
3300 
3302 
3310 
3311 
3313 
3321 
3322 
3324 
3332 
3333 
3335  bool empty();
3336 
3337 
3339 
3346  int size();
3347 
3348 
3350 
3359  bool hasKey(string k);
3360 
3361 
3363 
3372  bool hasKeyValue(string k);
3373 
3374 
3376 
3385  *string firstKey();
3386 
3387 
3389 
3398  *string lastKey();
3399 
3400 
3402  abstract string getElementName();
3403  };
3404 
3407 
3408 public:
3409 private:
3410 
3411 public:
3412 
3413  private :
3414  softlist l;
3415 
3416 public:
3417 
3419  constructor(softlist nl);
3420 
3421 
3423 
3434  abstract any get(softint i);
3435 
3437  add(any val);
3438 
3439 
3441  any take(int i);
3442 
3443 
3445  list getList();
3446 
3447 
3449 
3458  bool val();
3459 
3460 
3462 
3470 
3471 
3473  bool empty();
3474 
3475 
3477 
3484  int size();
3485 
3486 
3488  abstract string getElementName();
3489 
3490  private checkIndex(int i);
3491 
3492  };
3493 
3496 
3497 public:
3499  constructor();
3500 
3501 
3503  constructor(AbstractDatasource ds, hash tables, *hash opt);
3504 
3505 
3507  constructor(AbstractDatasource ds);
3508 
3509 
3511  add(string k, Table val);
3512 
3513 
3515  add(string k, AbstractTable val);
3516 
3517 
3519  add(Table val);
3520 
3521 
3523  add(AbstractTable val);
3524 
3525 
3527  AbstractTable take(string k);
3528 
3529 
3531  populate(AbstractDatasource ds, hash tables, *hash opt);
3532 
3533 
3535  populate(AbstractDatasource ds);
3536 
3537 
3539 
3553  *list getDropAllForeignConstraintsOnTableSql(string name, *hash opt);
3554 
3555 
3557 
3572  AbstractTable memberGate(string k);
3573 
3574 
3576  string getElementName();
3577 
3578 
3580  *AbstractTable getIfExists(AbstractDatasource ds, string name);
3581 
3582 
3584  AbstractTable get(AbstractDatasource ds, string name);
3585 
3586 
3588 
3603  *string getRenameTableIfExistsSql(string old_name, string new_name, *hash opts);
3604 
3605 
3607 
3618  bool tableRenamed(string old_name, string new_name, string old_sql_name);
3619 
3620 
3621  private tableRenamedIntern(string old_name, string new_name, string oldsn);
3622 
3623 
3625 
3640  *string getDropConstraintIfExistsSql(string tname, string cname, *hash opts);
3641 
3642 
3643  list getCreateList();
3644 
3645 
3646  Qore::AbstractIterator createIterator();
3647 
3648 
3650 
3658  list getDropList();
3659 
3660 
3662 
3670 
3671 
3672  private getDependencies(reference tdh, reference sdh, *reference th);
3673 
3674  };
3675 
3678 
3679 public:
3680  constructor(*hash c);
3681 
3682 
3684  add(string k, AbstractColumn val);
3685 
3686 
3688  AbstractColumn take(string k);
3689 
3690 
3692 
3707  AbstractColumn memberGate(string k);
3708 
3709 
3711  Columns subset(softlist l);
3712 
3713 
3715  string getElementName();
3716 
3717 
3719  bool equal(Columns cols);
3720 
3721  };
3722 
3725 
3726 public:
3727  public :
3729  string name;
3730 
3732  string native_type;
3733 
3735  *string qore_type;
3736 
3738  int size;
3739 
3741  bool nullable;
3742 
3744  *string def_val;
3745 
3747  *string comment;
3748 
3749 public:
3750 
3751  constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string c);
3752 
3753 
3755  string getNativeTypeString();
3756 
3757 
3759  string getCreateSql(AbstractTable t);
3760 
3761 
3763 
3772  abstract list getAddColumnSql(AbstractTable t);
3773 
3775  string getDropSql(string table_name);
3776 
3777 
3779 
3792 
3793 
3795 
3805  abstract string getRenameSql(AbstractTable t, string new_name);
3806 
3808  bool equal(AbstractColumn c);
3809 
3810 
3812  private abstract bool equalImpl(AbstractColumn c);
3813 
3815 
3827  private abstract list getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash opt);
3828  };
3829 
3832 
3833 public:
3834  public :
3836  int scale;
3837 
3838 public:
3839 
3840  constructor(softint n_scale = 0);
3841 
3842 
3844  string getNativeTypeString(string native_type, int precision);
3845 
3846  };
3847 
3850 
3851 public:
3852  constructor(*hash c);
3853 
3854 
3856  add(string k, AbstractIndex val);
3857 
3858 
3861 
3862 
3864  AbstractIndex take(string k);
3865 
3866 
3868 
3883  AbstractIndex memberGate(string k);
3884 
3885 
3886  string getElementName();
3887 
3888  };
3889 
3892 
3893 public:
3894  public :
3896  string name;
3897 
3899  bool unique;
3900 
3903 
3904 public:
3905 
3906  private :
3909 
3910 public:
3911 
3913  constructor(string n, bool u, hash c);
3914 
3915 
3917  string getName();
3918 
3919 
3921  bool hasColumn(string cname);
3922 
3923 
3925  abstract string getCreateSql(string table_name, *hash opt);
3926 
3928  string getDropSql(string table_name);
3929 
3930 
3932  bool equal(AbstractIndex ix);
3933 
3934 
3936  bool equalExceptName(AbstractIndex ix);
3937 
3938 
3940  abstract bool equalImpl(AbstractIndex ix);
3941 
3943  abstract string getRenameSql(string table_name, string new_name);
3944 
3947 
3948 
3951 
3952 
3955 
3956 
3958  list getRecreateSql(AbstractDatasource ds, string table_name, *hash opt);
3959 
3960  };
3961 
3964 
3965 public:
3966  constructor(*hash c);
3967 
3968 
3970  add(string k, AbstractConstraint val);
3971 
3972 
3974  AbstractConstraint take(string k);
3975 
3976 
3979 
3980 
3982 
3997  AbstractConstraint memberGate(string k);
3998 
3999 
4000  string getElementName();
4001 
4002  };
4003 
4006 
4007 public:
4008 private:
4009 
4010 public:
4011 
4012  private :
4014  string name;
4015 
4016 public:
4017 
4019  constructor(string n);
4020 
4021 
4023  string getName();
4024 
4025 
4027  rename(string n);
4028 
4029 
4031  abstract string getCreateSql(string table_name, *hash opt);
4032 
4034  string getDropSql(string table_name);
4035 
4036 
4038  abstract list getRenameSql(string table_name, string new_name);
4039 
4041  string getDisableSql(string table_name);
4042 
4043 
4045  string getEnableSql(string table_name, *hash opt);
4046 
4047 
4049  bool equal(AbstractConstraint c);
4050 
4051 
4053  private abstract bool equalImpl(AbstractConstraint c);
4054 
4056  abstract bool setIndexBase(string ix);
4057 
4059  abstract clearIndex();
4060 
4062  bool hasColumn(string cname);
4063 
4064  };
4065 
4068 
4069 public:
4070  public :
4072  string src;
4073 
4074 public:
4075 
4077  constructor(string n, string n_src);
4078 
4079 
4081  private bool equalImpl(AbstractConstraint c);
4082 
4083 
4085  bool setIndexBase(string ix);
4086 
4087 
4089  clearIndex();
4090 
4091  };
4092 
4095 
4096 public:
4097  private :
4100 
4102  *string index;
4103 
4104 public:
4105 
4107  constructor(string n, *hash c, *string n_index);
4108 
4109 
4111  abstract string getCreateSql(string table_name, *hash opts);
4112 
4114  private bool equalImpl(AbstractConstraint c);
4115 
4116 
4118 
4123 
4124 
4126  hash getDisableReenableSql(AbstractDatasource ds, string table_name, *hash opts);
4127 
4128 
4130  findMatchingIndex(*Indexes indexes);
4131 
4132 
4134 
4145 
4146 
4148  removeSourceConstraint(string tname, list cols);
4149 
4150 
4152  renameSourceConstraintTable(string old_name, string new_name);
4153 
4154 
4156  bool hasColumn(string cname);
4157 
4158 
4160  *string getIndex();
4161 
4162  };
4163 
4166 
4167 public:
4168  constructor();
4169 
4170 
4171  constructor(string n, *hash c);
4172 
4173  };
4174 
4177 
4178 public:
4179  constructor(*hash c);
4180 
4181 
4183  add(string k, AbstractForeignConstraint val);
4184 
4185 
4187  AbstractForeignConstraint take(string k);
4188 
4189 
4192 
4193 
4195 
4211 
4212 
4214  *hash findConstraintOn(string table, softlist cols);
4215 
4216 
4218  string getElementName();
4219 
4220  };
4221 
4224 
4225 public:
4226  public :
4228  string table;
4229 
4232 
4233 public:
4234 
4236  constructor(string t, Columns c);
4237 
4238 
4240  bool equal(ForeignConstraintTarget targ);
4241 
4242  };
4243 
4246 
4247 public:
4248  public :
4251 
4254 
4255 public:
4256 
4257  constructor(string n, Columns c, ForeignConstraintTarget t);
4258 
4259 
4261  private bool equalImpl(AbstractConstraint con);
4262 
4263 
4265  bool hasColumn(string cname);
4266 
4267 
4269  bool setIndexBase(string ix);
4270 
4271 
4273  clearIndex();
4274 
4275  };
4276 
4279 
4280 public:
4281  public :
4283  string name;
4284 
4287 
4290 
4293 
4294 public:
4295 
4297  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_max);
4298 
4299 
4301  abstract string getCreateSql(*hash opt);
4302 
4304  string getDropSql();
4305 
4306 
4308  abstract string getRenameSql(string new_name);
4309  };
4310 
4313 
4314 public:
4315  public :
4316  // ! potential object schema
4317  *string schema;
4318 
4320  string name;
4321 
4323  string src;
4324 
4327 
4328 public:
4329 
4331  constructor(string n_name, string n_src);
4332 
4333 
4335  abstract string getCreateSql(*hash opt);
4336 
4338  string getDropSql();
4339 
4340 
4342  abstract softlist getRenameSql(string new_name);
4343 
4344  };
4345 
4348 
4349 public:
4350  public :
4352  string name;
4353 
4355  string type;
4356 
4358  string src;
4359 
4360 public:
4361 
4363 
4367  constructor(string n, string n_type, string n_src);
4368 
4369 
4371  string getType();
4372 
4373 
4374  // FIXME: not appropriate for pgsql triggers for example
4376  string getDropSql();
4377 
4378 
4380  bool equal(AbstractFunctionBase t);
4381 
4382 
4384  private abstract bool equalImpl(AbstractFunctionBase t);
4385  };
4386 
4389 
4390 public:
4392 
4396  constructor(string n, string n_type, string n_src);
4397 
4398 
4400  abstract list getCreateSql(*hash opt);
4401 
4403  abstract list getRenameSql(string new_name);
4404 
4406  setName(string new_name);
4407 
4408  };
4409 
4412 
4413 public:
4414  constructor(*hash c);
4415 
4416 
4418  add(string k, AbstractFunction val);
4419 
4420 
4422  AbstractFunction take(string k);
4423 
4424 
4426 
4441  AbstractFunction memberGate(string k);
4442 
4443 
4444  string getElementName();
4445 
4446  };
4447 
4450 
4451 public:
4453  constructor(string n, string n_src);
4454 
4455 
4457  abstract list getCreateSql(string table_name, *hash opt);
4458 
4460  abstract list getRenameSql(string table_name, string new_name);
4461 
4463  abstract list getDropSql(string table_name);
4464  };
4465 
4468 
4469 public:
4470  constructor(*hash c);
4471 
4472 
4474  add(string k, AbstractTrigger val);
4475 
4476 
4478  AbstractTrigger take(string k);
4479 
4480 
4482 
4497  AbstractTrigger memberGate(string k);
4498 
4499 
4500  string getElementName();
4501 
4502  };
4503 
4505 
4515  class Database {
4516 
4517 public:
4518  private :
4521 
4522 public:
4523 
4525 
4536  constructor(AbstractDatasource ds, *hash opts);
4537 
4538 
4540 
4550  constructor(string ds, *hash opts);
4551 
4552 
4554 
4572  constructor(hash ds, *hash opts);
4573 
4574 
4576 
4587  any tryExec(string sql);
4588 
4589 
4591 
4601  any tryExecArgs(string sql, *softlist args);
4602 
4603 
4605 
4616  any tryExecRaw(string sql);
4617 
4618 
4620 
4634  list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache);
4635 
4636 
4638 
4651  list getDropSchemaSql(hash schema_hash, *hash opt);
4652 
4653 
4656 
4657 
4659  any methodGate(string meth);
4660 
4661 
4663 
4677  AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
4678 
4679 
4681 
4694  AbstractTable makeTable(string name, hash desc, *hash opts);
4695 
4696 
4698 
4709  AbstractFunction makeFunction(string name, string src, *hash opt);
4710 
4711 
4713 
4724  AbstractFunction makeProcedure(string name, string src, *hash opt);
4725 
4726 
4728 
4740  bool dropFunctionIfExists(string name, *hash opt);
4741 
4742 
4744 
4756  bool dropProcedureIfExists(string name, *hash opt);
4757 
4758 
4760 
4772  bool dropSequenceIfExists(string name, *hash opt);
4773 
4774 
4776 
4788  bool dropTableIfExists(string name, *hash opt);
4789 
4790 
4792 
4805 
4806 
4808 
4821 
4822 
4824 
4833  *AbstractTable getTable(string name);
4834 
4835 
4837 
4846  *AbstractSequence getSequence(string name);
4847 
4848 
4850 
4861  *AbstractFunction getFunction(string name);
4862 
4863 
4865 
4876  *AbstractFunction getProcedure(string name);
4877 
4878 
4880 
4889  *AbstractView getView(string name);
4890 
4891 
4893 
4902  int getNextSequenceValue(string name);
4903 
4904 
4906 
4915  string getSqlFromList(list l);
4916 
4917 
4919  bool supportsSequences();
4920 
4921 
4923  list listTables();
4924 
4925 
4928 
4929 
4931  list listFunctions();
4932 
4933 
4936 
4937 
4939  list listProcedures();
4940 
4941 
4944 
4945 
4947  list listSequences();
4948 
4949 
4952 
4953 
4955  list listViews();
4956 
4957 
4960 
4961  };
4962 
4965 
4966 public:
4967  private :
4969  AbstractDatasource ds;
4971  string dsdesc;
4973  Mutex l();
4976 
4977 public:
4978 
4980 
4985  private constructor(AbstractDatasource nds, *hash nopts);
4986 
4987 
4988  static string makeDatasourceDesc(AbstractDatasource ds);
4989 
4990  private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
4991 
4992 
4993 
4994 private:
4995  static validateOptionIntern(string err, string type, reference opt, string k, string tag);
4996 public:
4997 
4998 
5000  private validateHashKeysForWhitespaces(any node);
5001 
5002 
5005 
5006 
5008  string getDriverName();
5009 
5010 
5012  string getDatasourceDesc();
5013 
5014  };
5015 
5018 
5019 public:
5020  public :
5022 
5026  "native_case": Type::Boolean,
5027  );
5028 
5030 
5033  const CacheOptions = (
5034  "table_cache": "Tables",
5035  );
5036 
5038 
5044  "info_callback": "code",
5045  "sql_callback": "code",
5046  "sql_callback_executed": Type::Boolean,
5047  );
5048 
5057  const AC_Unchanged = 0;
5059 
5061  const AC_Create = 1;
5062 
5064  const AC_Drop = 2;
5065 
5067  const AC_Rename = 3;
5068 
5070  const AC_Modify = 4;
5071 
5073  const AC_Truncate = 5;
5074 
5076  const AC_Add = 6;
5077 
5079  const AC_Recreate = 7;
5080 
5082  const AC_Insert = 8;
5083 
5085  const AC_Update = 9;
5086 
5088  const AC_Delete = 10;
5089 
5091  const AC_NotFound = 11;
5093 
5095  const ActionMap = (
5096  AC_Unchanged: "unchanged",
5097  AC_Create: "create",
5098  AC_Drop: "drop",
5099  AC_Rename: "rename",
5100  AC_Modify: "modify",
5101  AC_Truncate: "truncate",
5102  AC_Add: "add",
5103  AC_Recreate: "recreate",
5104  AC_Insert: "insert",
5105  AC_Update: "update",
5106  AC_Delete: "delete",
5107  AC_NotFound: "not found",
5108  );
5109 
5111  const ActionDescMap = (
5112  "unchanged": AC_Unchanged,
5113  "create": AC_Create,
5114  "drop": AC_Drop,
5115  "rename": AC_Rename,
5116  "modify": AC_Modify,
5117  "truncate": AC_Truncate,
5118  "add": AC_Add,
5119  "recreate": AC_Recreate,
5120  "insert": AC_Insert,
5121  "update": AC_Update,
5122  "delete": AC_Delete,
5123  "not found": AC_NotFound,
5124  );
5125 
5128  AC_Unchanged: ".",
5129  AC_Create: "C",
5130  AC_Drop: "D",
5131  AC_Rename: "N",
5132  AC_Modify: "M",
5133  AC_Truncate: "T",
5134  AC_Add: "A",
5135  AC_Recreate: "R",
5136  AC_Insert: "I",
5137  AC_Update: "U",
5138  AC_Delete: "X",
5139  AC_NotFound: ".",
5140  );
5141 
5143 
5150  "replace": Type::Boolean,
5151  "table_cache": "Tables",
5152  "data_tablespace": Type::String,
5153  "index_tablespace": Type::String,
5154  );
5155 
5157 
5160 
5162 
5165 
5167 
5180  "tables": Type::Hash,
5181  "table_map": Type::Hash,
5182 
5183  "sequences": Type::Hash,
5184  "sequence_map": Type::Hash,
5185 
5186  "functions": Type::Hash,
5187  "function_map": Type::Hash,
5188 
5189  "procedures": Type::Hash,
5190  "procedure_map": Type::Hash,
5191 
5192  //"views": Type::Hash,
5193  //"view_map": Type::Hash,
5194  );
5195 
5197 
5203  "start": Type::Int,
5204  "increment": Type::Int,
5205  "end": Type::Int,
5206  );
5207 
5208 public:
5209 
5210  private :
5213 
5214 public:
5215 
5217 
5222  private constructor(AbstractDatasource nds, *hash nopts);
5223 
5224 
5226  list features();
5227 
5228 
5229  static doOkCallback(*hash opt, int ac, string type, string name, *string table, *string info);
5230 
5231  static *string doCallback(*hash opt, *string sql, int ac, string type, string name, *string table, *string new_name, *string info);
5232 
5233  static list doCallback(*hash opt, list sql, int ac, string type, string name, *string table, *string new_name, *string info);
5234 
5235 /*
5236  static *string doCallback(*hash opt, *string sql, string fmt) {
5237  if (!sql)
5238  return;
5239  if (opt.info_callback)
5240  opt.info_callback(vsprintf(fmt, argv));
5241  if (opt.sql_callback)
5242  opt.sql_callback(sql);
5243  return sql;
5244  }
5245 
5246  static list doCallback(*hash opt, list sql, string fmt) {
5247  if (sql) {
5248  if (opt.info_callback)
5249  opt.info_callback(vsprintf(fmt, argv));
5250  if (opt.sql_callback)
5251  map opt.sql_callback($1), sql;
5252  }
5253  return sql;
5254  }
5255 */
5256 
5258 
5269  any tryExec(string sql);
5270 
5271 
5273 
5283  any tryExecArgs(string sql, *softlist args);
5284 
5285 
5287 
5298  any tryExecRaw(string sql);
5299 
5300 
5302 
5316  list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache);
5317 
5318 
5320 
5333  list getDropSchemaSql(hash schema_hash, *hash opt);
5334 
5335 
5336  private list dropSqlUnlocked(string type, hash schema_hash, code get, code make, *hash opt, string make_arg_type);
5337 
5338 
5339  private list alignCodeUnlocked(string type, hash schema_hash, code get, code make, *hash opt, string make_arg_type);
5340 
5341 
5343 
5357  AbstractSequence makeSequence(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
5358 
5359 
5360  AbstractSequence makeSequenceFromDescription(string name, *hash sh, *hash opts);
5361 
5362 
5364 
5377  AbstractTable makeTable(string name, hash desc, *hash opts);
5378 
5379 
5381 
5392  AbstractFunction makeFunction(string name, string src, *hash opts);
5393 
5394 
5396 
5407  AbstractFunction makeProcedure(string name, string src, *hash opt);
5408 
5409 
5411 
5423  bool dropFunctionIfExists(string name, *hash opt);
5424 
5425 
5427 
5439  bool dropProcedureIfExists(string name, *hash opt);
5440 
5441 
5443 
5455  bool dropSequenceIfExists(string name, *hash opt);
5456 
5457 
5459 
5471  bool dropViewIfExists(string name, *hash opt);
5472 
5473 
5475 
5487  bool dropTableIfExists(string name, *hash opt);
5488 
5489 
5491 
5503  *string getDropFunctionSqlIfExists(string name, *hash opt);
5504 
5505 
5507 
5519  *string getDropProcedureSqlIfExists(string name, *hash opt);
5520 
5521 
5523 
5535  *string getDropSequenceSqlIfExists(string name, *hash opt);
5536 
5537 
5539 
5551  *list getDropTableSqlIfExists(string name, *hash opt);
5552 
5553 
5554  doDropSql(*softlist l, string type, string name, *hash opt);
5555 
5556 
5557  bool doDrop(*softlist l, string type, string name, *hash opt);
5558 
5559 
5561 
5574 
5575 
5577 
5590 
5591 
5593 
5602  *AbstractTable getTable(string name);
5603 
5604 
5606 
5615  *AbstractSequence getSequence(string name);
5616 
5617 
5619 
5630  *AbstractFunction getFunction(string name);
5631 
5632 
5634 
5645  *AbstractFunction getProcedure(string name);
5646 
5647 
5649 
5658  *AbstractView getView(string name);
5659 
5660 
5662 
5671  int getNextSequenceValue(string name);
5672 
5673 
5675 
5684  string getSqlFromList(list l);
5685 
5686 
5688  bool supportsSequences();
5689 
5690 
5692  bool supportsTypes();
5693 
5694 
5696  bool supportsPackages();
5697 
5698 
5700  list listTables();
5701 
5702 
5705 
5706 
5708  list listFunctions();
5709 
5710 
5713 
5714 
5716  list listProcedures();
5717 
5718 
5721 
5722 
5724  list listSequences();
5725 
5726 
5729 
5730 
5732  list listViews();
5733 
5734 
5737 
5738 
5739  private validateOptionsIntern(string err, hash ropt, reference opt);
5740 
5741 
5742  private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
5743 
5744 
5745  static AbstractDatabase getDatabase(AbstractDatasource nds, *hash opts);
5746 
5747  static AbstractDatabase getDatabase(string dsstr, *hash opts);
5748 
5749  static AbstractDatabase getDatabase(hash dsh, *hash opts);
5750 
5751  static checkDriverOptions(reference h, string drv);
5752 
5754  private hash getDatabaseOptions();
5755 
5756 
5758  private hash getCallbackOptions();
5759 
5760 
5762  private hash getCreationOptions();
5763 
5764 
5766  private hash getCacheOptions();
5767 
5768 
5770  private hash getAlignSchemaOptions();
5771 
5772 
5774  private hash getDropSchemaOptions();
5775 
5776 
5779 
5780 
5783 
5784 
5786  private any tryExecArgsImpl(string sql, *softlist args);
5787 
5788 
5790  private any tryExecRawImpl(string sql);
5791 
5792 
5793  private abstract string getCreateSqlImpl(list l);
5794  private abstract list getAlignSqlImpl(hash schema_hash, *hash opt);
5795  private abstract list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
5796 
5797  private abstract *AbstractSequence getSequenceImpl(string name);
5798  private abstract *AbstractFunction getFunctionImpl(string name);
5799  private abstract *AbstractFunction getProcedureImpl(string name);
5800  private abstract *AbstractView getViewImpl(string name);
5801 
5802  private abstract AbstractSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
5803  private abstract AbstractFunction makeFunctionImpl(string name, string src, *hash opts);
5804  private abstract AbstractFunction makeProcedureImpl(string name, string src, *hash opts);
5805 
5806  private abstract list featuresImpl();
5807  private abstract list listTablesImpl();
5808  private abstract list listFunctionsImpl();
5809  private abstract list listProceduresImpl();
5810  private abstract list listSequencesImpl();
5811  private abstract list listViewsImpl();
5812 
5814  private abstract int getNextSequenceValueImpl(string name);
5815 
5817  private abstract bool supportsSequencesImpl();
5818  private abstract bool supportsPackagesImpl();
5819  private abstract bool supportsTypesImpl();
5820  };
5821 
5823 
5833  class Table {
5834 
5835 public:
5836  private :
5839 
5840 public:
5841 
5843 
5855  constructor(AbstractDatasource ds, string name, *hash opts);
5856 
5857 
5859 
5871  constructor(string ds, string name, *hash opts);
5872 
5873 
5875 
5895  constructor(hash ds, string name, *hash opts);
5896 
5897 
5899 
5907  constructor(AbstractDatasource ds, hash desc, string name, *hash opts);
5908 
5909 
5911 
5922  setDatasource(AbstractDatasource nds);
5923 
5924 
5926  commit();
5927 
5928 
5930  rollback();
5931 
5932 
5934  string getName();
5935 
5936 
5939 
5940 
5943 
5944 
5946  any methodGate(string meth);
5947 
5948 
5950 
5954  bool checkExistence();
5955 
5956 
5958 
5967  bool inDb();
5968 
5969 
5971 
5977  setupTable(hash desc, *hash opt);
5978 
5979 
5981 
5989 
5990 
5992 
6003  drop(*hash opt);
6004 
6005 
6007 
6018  dropNoCommit(*hash opt);
6019 
6020 
6022 
6033  any tryExec(string sql);
6034 
6035 
6037 
6047  any tryExecArgs(string sql, *softlist args);
6048 
6049 
6051 
6062  any tryExecRaw(string sql);
6063 
6064 
6066 
6073  truncate();
6074 
6075 
6077 
6084  truncateNoCommit();
6085 
6086 
6088 
6103  string getTruncateSql(*hash opt);
6104 
6105 
6107 
6118  create(*hash opt);
6119 
6120 
6122 
6131  createNoCommit(*hash opt);
6132 
6133 
6135 
6146  rename(string new_name, *reference sql, *Tables table_cache);
6147 
6148 
6150 
6161  bool emptyData();
6162 
6163 
6165 
6174  bool empty();
6175 
6176 
6178 
6202  AbstractColumn addColumn(string cname, hash opt, bool nullable = True, *reference lsql);
6203 
6204 
6206 
6234  list getAddColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
6235 
6236 
6238 
6264  AbstractColumn modifyColumn(string cname, hash opt, bool nullable = True, *reference lsql);
6265 
6266 
6268 
6294  list getModifyColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
6295 
6296 
6298 
6314  AbstractColumn renameColumn(string old_name, string new_name, reference sql);
6315 
6316 
6318 
6336  string getRenameColumnSql(string old_name, string new_name, *hash opt);
6337 
6338 
6340 
6361  AbstractPrimaryKey addPrimaryKey(string cname, softlist cols, *hash opt, *reference sql);
6362 
6363 
6365 
6387  string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt);
6388 
6389 
6391 
6409  AbstractPrimaryKey dropPrimaryKey(*reference lsql);
6410 
6411 
6413 
6433 
6434 
6436 
6459  AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql);
6460 
6461 
6463 
6483  string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt);
6484 
6485 
6487 
6509  AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql);
6510 
6511 
6513 
6534  string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt);
6535 
6536 
6538 
6550  AbstractIndex renameIndex(string old_name, string new_name, reference sql);
6551 
6552 
6554 
6573  string getDropIndexSql(string iname, *hash opt);
6574 
6575 
6577 
6596  string getDropConstraintSql(string cname, *hash opt);
6597 
6598 
6600 
6619  *string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref);
6620 
6621 
6623 
6641  AbstractIndex dropIndex(string iname, *reference sql);
6642 
6643 
6645 
6668  AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
6669 
6670 
6672 
6694  string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt);
6695 
6696 
6698 
6716  AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql);
6717 
6718 
6720 
6736 
6737 
6739 
6759  AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql);
6760 
6761 
6763 
6785  string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt);
6786 
6787 
6789 
6801  AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql);
6802 
6803 
6805 
6823  AbstractConstraint dropConstraint(string cname, *reference sql);
6824 
6825 
6827 
6847  AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql);
6848 
6849 
6851 
6873  list getAddTriggerSql(string tname, string src, *hash topt, *hash opt);
6874 
6875 
6877 
6895  AbstractTrigger dropTrigger(string tname, *reference sql);
6896 
6897 
6899 
6918  list getDropTriggerSql(string tname, *hash opt);
6919 
6920 
6922 
6933  string getSqlValue(any v);
6934 
6935 
6937 
6953  AbstractColumn dropColumn(string cname, *reference lsql);
6954 
6955 
6957 
6976  list getDropColumnSql(string cname, *hash opt);
6977 
6978 
6980 
6990  insert(hash row, *reference sql);
6991 
6992 
6994 
7004  insertNoCommit(hash row, *reference sql);
7005 
7006 
7008 
7018  insert(hash row, *hash opt);
7019 
7020 
7022 
7032  insertNoCommit(hash row, *hash opt);
7033 
7034 
7036 
7054  int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql);
7055 
7056 
7058 
7076  int insertFromSelect(list cols, Table source, *hash sh, *reference sql);
7077 
7078 
7080 
7098  int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql);
7099 
7100 
7102 
7120  int insertFromSelectNoCommit(list cols, Table source, *hash sh, *reference sql);
7121 
7122 
7124 
7142  int insertFromSelect(list cols, AbstractTable source, *hash sh, *hash opt);
7143 
7144 
7146 
7164  int insertFromSelect(list cols, Table source, *hash sh, *hash opt);
7165 
7166 
7168 
7186  int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *hash opt);
7187 
7188 
7190 
7208  int insertFromSelectNoCommit(list cols, Table source, *hash sh, *hash opt);
7209 
7210 
7212 
7231 
7232 
7234 
7253 
7254 
7256 
7276  int upsert(hash row, int upsert_strategy = AbstractTable::UpsertAuto);
7277 
7278 
7280 
7300  int upsertNoCommit(hash row, int upsert_strategy = AbstractTable::UpsertAuto);
7301 
7302 
7304 
7329  code getUpsertClosure(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto);
7330 
7331 
7333 
7358  code getUpsertClosureWithValidation(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto);
7359 
7360 
7362 
7392 
7393 
7395 
7425 
7426 
7428 
7465  *hash upsertFromSelect(AbstractTable src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
7466 
7467 
7469 
7508  *hash upsertFromSelectNoCommit(AbstractTable src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
7509 
7510 
7512 
7549  *hash upsertFromSelect(Table src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
7550 
7551 
7553 
7592  *hash upsertFromSelectNoCommit(Table src, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
7593 
7594 
7596 
7607  softint rowCount();
7608 
7609 
7611 
7628  Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql);
7629 
7630 
7632 
7650 
7651 
7653 
7671  *hash selectRow(*hash sh, *reference sql);
7672 
7673 
7675 
7692  *list selectRows(*hash sh, *reference sql);
7693 
7694 
7696 
7713  *hash select(*hash sh, *reference sql);
7714 
7715 
7717 
7735  *hash selectRow(*hash sh, *hash opt);
7736 
7737 
7739 
7756  *list selectRows(*hash sh, *hash opt);
7757 
7758 
7760 
7777  *hash select(*hash sh, *hash opt);
7778 
7779 
7781 
7799  string getSelectSql(*hash sh, *reference args);
7800 
7801 
7803 
7817  int del(*hash cond, *reference sql);
7818 
7819 
7821 
7835  int delNoCommit(*hash cond, *reference sql);
7836 
7837 
7839 
7855  int update(hash set, *hash cond, *reference sql);
7856 
7857 
7859 
7875  int updateNoCommit(hash set, *hash cond, *reference sql);
7876 
7877 
7879 
7893  int del(*hash cond, *hash opt);
7894 
7895 
7897 
7911  int delNoCommit(*hash cond, *hash opt);
7912 
7913 
7915 
7931  int update(hash set, *hash cond, *hash opt);
7932 
7933 
7935 
7951  int updateNoCommit(hash set, *hash cond, *hash opt);
7952 
7953 
7955 
7964  string getSqlFromList(list l);
7965 
7966 
7968 
7986  string getRenameSql(string new_name, *hash opt);
7987 
7988 
7990 
8001  string getCreateSqlString(*hash opt);
8002 
8003 
8005 
8014  list getCreateSql(*hash opt);
8015 
8016 
8018 
8029  string getCreateTableSql(*hash opt);
8030 
8031 
8033 
8044  *list getCreateIndexesSql(*hash opt);
8045 
8046 
8048 
8059  *string getCreatePrimaryKeySql(*hash opt);
8060 
8061 
8063 
8075 
8076 
8078 
8092 
8093 
8095 
8106  *list getCreateMiscSql(*hash opt);
8107 
8108 
8110 
8122 
8123 
8125 
8138  list getAlignSql(AbstractTable table, *hash opt);
8139 
8140 
8142 
8155  list getAlignSql(Table table, *hash opt);
8156 
8157 
8159 
8172  string getAlignSqlString(AbstractTable table, *hash opt);
8173 
8174 
8176 
8189  string getAlignSqlString(Table table, *hash opt);
8190 
8191 
8193 
8204  *hash find(any id);
8205 
8206 
8208 
8219  *list find(list ids);
8220 
8221 
8223 
8234  *hash find(hash row);
8235 
8236 
8238 
8253  *hash findSingle(*hash cond);
8254 
8255 
8257 
8270  *list findAll(*hash cond);
8271 
8272 
8274 
8281  cache(*hash opts);
8282 
8283 
8285 
8291  clear();
8292 
8293 
8295 
8302  Columns describe();
8303 
8304 
8306 
8316 
8317 
8319 
8329 
8330 
8332 
8341  Indexes getIndexes();
8342 
8343 
8345 
8355 
8356 
8359 
8360 
8363 
8364 
8366  string getDriverName();
8367 
8368  };
8369 
8372 
8373 public:
8374  public :
8376 
8380  const TableOptions = (
8381  "native_case": Type::Boolean,
8382  "table_cache": "Tables",
8383  );
8384 
8386 
8390  const IndexOptions = (
8391  "index_tablespace": Type::String,
8392  "replace": Type::Boolean,
8393  );
8394 
8396 
8399 
8401  const CacheOptions = (
8402  "table_cache": "Tables",
8403  );
8404 
8406 
8410  "table_cache": "Tables",
8411  );
8412 
8414 
8417 
8419 
8432  const SelectOptions = (
8433  "comment": Type::String,
8434  "hint": Type::String,
8435  "columns": Type::NothingType,
8436  "where": "hash/list",
8437  "orderby": "softstringhashlist",
8438  "desc": Type::Boolean,
8439  "limit": Type::Int,
8440  "offset": Type::Int,
8441  "join": Type::Hash,
8442  "groupby": "softstringhashlist",
8443  "having": Type::Hash,
8444  "superquery": Type::Hash,
8445  "forupdate": Type::Boolean,
8446  );
8447 
8450  "indexes": True,
8451  "foreign_constraints": True,
8452  "triggers": True,
8453  );
8454 
8456 
8460  "omit": "softstringlist",
8461  );
8462 
8464 
8472  "column_map": Type::Hash,
8473  "index_map": Type::Hash,
8474  "constraint_map": Type::Hash,
8475  "trigger_map": Type::Hash,
8476  "db_table_cache": "Tables",
8477  );
8478 
8480 
8492  "columns": Type::Hash,
8493  "primary_key": Type::Hash,
8494  "indexes": Type::Hash,
8495  "triggers": Type::Hash,
8496  "foreign_constraints": Type::Hash,
8497  "unique_constraints": Type::Hash,
8498  //"check_constraints": Type::Hash,
8499  "table_cache": "Tables",
8500  );
8501 
8503 
8515  "qore_type": Type::String,
8516  "native_type": Type::String,
8517  "size": Type::Int,
8518  "scale": Type::Int,
8519  "default_value": Type::NothingType,
8520  "comment": Type::String,
8521  );
8522 
8524 
8528  "notnull": Type::Boolean,
8529  );
8530 
8532  const ColumnOptions = hash();
8533 
8535 
8539  "sqlarg_callback": "code",
8540  );
8541 
8543 
8548  const UpsertOptions = (
8549  "info_callback": "code",
8550  "commit_block": Type::Int,
8551  "delete_others": Type::Boolean,
8552  );
8553 
8555 
8560  "info_callback": "code",
8561  "commit_block": Type::Int,
8562  );
8563 
8578 
8585 
8587 
8593 
8595 
8602 
8604 
8608  const UpsertAuto = 4;
8609 
8611 
8615  const UpsertInsertOnly = 5;
8616 
8618 
8621  UpsertInsertFirst: "UpsertInsertFirst",
8622  UpsertUpdateFirst: "UpsertUpdateFirst",
8623  UpsertSelectFirst: "UpsertSelectFirst",
8624  UpsertAuto: "UpsertAuto",
8625  UpsertInsertOnly: "UpsertInsertOnly",
8626  );
8627 
8629 
8632  "UpsertInsertFirst": UpsertInsertFirst,
8633  "UpsertUpdateFirst": UpsertUpdateFirst,
8634  "UpsertSelectFirst": UpsertSelectFirst,
8635  "UpsertAuto": UpsertAuto,
8636  "UpsertInsertOnly": UpsertInsertOnly,
8637  );
8639 
8644  const UR_Inserted = 1;
8646 
8648  const UR_Verified = 2;
8649 
8651  const UR_Updated = 3;
8652 
8654  const UR_Unchanged = 4;
8655 
8657  const UR_Deleted = 5;
8659 
8661 
8664  UR_Inserted: "inserted",
8665  UR_Verified: "verified",
8666  UR_Updated: "updated",
8667  UR_Unchanged: "unchanged",
8668  UR_Deleted: "deleted",
8669  );
8670 
8672 
8675  "inserted": UR_Inserted,
8676  "verified": UR_Verified,
8677  "updated": UR_Updated,
8678  "unchanged": UR_Unchanged,
8679  "deleted": UR_Deleted,
8680  );
8681 
8684  UR_Inserted: "I",
8685  UR_Verified: "V",
8686  UR_Updated: "U",
8687  UR_Unchanged: ".",
8688  UR_Deleted: "X",
8689  );
8690 
8691 public:
8692 
8693  private :
8695  string name;
8711  bool inDb = False;
8713  bool manual = False;
8714 
8715 public:
8716 
8718 
8724  private constructor(AbstractDatasource nds, string nname, *hash nopts);
8725 
8726 
8728  copy(AbstractTable old);
8729 
8730 
8732 
8743  setDatasource(AbstractDatasource nds);
8744 
8745 
8746  private doTableOptions(*hash nopts);
8747 
8748 
8750  commit();
8751 
8752 
8754  rollback();
8755 
8756 
8758 
8767  bool inDb();
8768 
8769 
8771 
8779 
8780 
8782 
8793  drop(*hash opt);
8794 
8795 
8797 
8808  any tryExec(string sql);
8809 
8810 
8812 
8822  any tryExecArgs(string sql, *softlist args);
8823 
8824 
8826 
8837  any tryExecRaw(string sql);
8838 
8839 
8841 
8852  dropNoCommit(*hash opt);
8853 
8854 
8856 
8866  softlist getDropSql(*hash opt);
8867 
8868 
8870 
8877  truncate();
8878 
8879 
8881 
8888  truncateNoCommit();
8889 
8890 
8892 
8907  string getTruncateSql(*hash opt);
8908 
8909 
8911 
8920  create(*hash opt);
8921 
8922 
8924 
8935  createNoCommit(*hash opt);
8936 
8937 
8939 
8950  rename(string new_name, *reference sql, *Tables table_cache);
8951 
8952 
8953  private doRenameIntern(string new_name, *Tables table_cache);
8954 
8955 
8957 
8968  bool emptyData();
8969 
8970 
8972 
8981  bool empty();
8982 
8983 
8984  private bool emptyUnlocked();
8985 
8986 
8988 
8994  setupTable(hash desc, *hash opt);
8995 
8996 
8998 
9021  AbstractColumn addColumn(string cname, hash opt, bool nullable = True, *reference lsql);
9022 
9023 
9025 
9053  list getAddColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
9054 
9055 
9056  private AbstractColumn addColumnUnlocked(string cname, hash opt, bool nullable = True, *reference lsql, bool do_exec = True, bool modify_table = True);
9057 
9058 
9059  private addColumnToTableUnlocked(AbstractColumn c);
9060 
9061 
9063 
9087  AbstractColumn modifyColumn(string cname, hash opt, bool nullable = True, *reference lsql);
9088 
9089 
9091 
9117  list getModifyColumnSql(string cname, hash copt, bool nullable = True, *hash opt);
9118 
9119 
9121 
9138  AbstractColumn renameColumn(string old_name, string new_name, reference sql);
9139 
9140 
9142 
9160  string getRenameColumnSql(string old_name, string new_name, *hash opt);
9161 
9162 
9163  private AbstractColumn renameColumnIntern(AbstractColumn c, string new_name);
9164 
9165 
9166  private validateOptionsIntern(string err, hash ropt, reference opt);
9167 
9168 
9169  private validateOptionsIntern(string err, hash ropt, reference opt, string tag);
9170 
9171 
9172  private execSql(softlist lsql);
9173 
9174 
9176 
9196  AbstractPrimaryKey addPrimaryKey(string pkname, softlist cols, *hash opt, *reference sql);
9197 
9198 
9200 
9222  string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt);
9223 
9224 
9225  private setPrimaryKeyUnlocked(AbstractPrimaryKey pk);
9226 
9227 
9228  private AbstractPrimaryKey addPrimaryKeyUnlocked(string pkname, softlist cols, *hash opt, *reference sql);
9229 
9230 
9231  private AbstractPrimaryKey addPrimaryKeyUnlockedIntern(string pkname, softlist cols, *hash opt, *reference sql);
9232 
9233 
9235 
9252 
9253 
9254  private list getDropAllConstraintsAndIndexesOnColumnSqlUnlocked(string cname, *hash opt);
9255 
9256 
9258 
9278 
9279 
9281 
9299  AbstractPrimaryKey dropPrimaryKey(*reference lsql);
9300 
9301 
9303 
9324  AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql);
9325 
9326 
9328 
9348  string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt);
9349 
9350 
9351  private AbstractUniqueConstraint addUniqueConstraintUnlocked(string cname, softlist cols, *hash opt, *reference sql);
9352 
9353 
9354  private AbstractUniqueConstraint addUniqueConstraintUnlockedIntern(string cname, softlist cols, *hash opt, *reference sql);
9355 
9356 
9358 
9379  AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql);
9380 
9381 
9383 
9404  string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt);
9405 
9406 
9407  private AbstractIndex addIndexUnlocked(string iname, bool unique, softlist cols, *hash opt, *reference sql);
9408 
9409 
9410  private AbstractIndex addIndexUnlockedIntern(string iname, bool unique, softlist cols, *hash opt, *reference sql);
9411 
9412 
9414 
9426  AbstractIndex renameIndex(string old_name, string new_name, reference sql);
9427 
9428 
9430 
9448  AbstractIndex dropIndex(string iname, *reference sql);
9449 
9450 
9452 
9471  string getDropIndexSql(string iname, *hash opt);
9472 
9473 
9475 
9497  AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
9498 
9499 
9501 
9523  string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt);
9524 
9525 
9526  private Columns getReferencedTableColumnsUnlocked(string table, *Tables cache, string err = "FOREIGN-CONSTRAINT-ERROR");
9527 
9528 
9529  private AbstractForeignConstraint addForeignConstraintUnlocked(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
9530 
9531 
9532  private AbstractForeignConstraint addForeignConstraintUnlockedIntern(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql);
9533 
9534 
9536 
9554  AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql);
9555 
9556 
9558 
9574 
9575 
9577 
9597  AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql);
9598 
9599 
9601 
9623  string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt);
9624 
9625 
9626  private AbstractCheckConstraint addCheckConstraintUnlocked(string cname, string src, *hash opt, *reference sql);
9627 
9628 
9629  private AbstractCheckConstraint addCheckConstraintUnlockedIntern(string cname, string src, *hash opt, *reference sql);
9630 
9631 
9633 
9645  AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql);
9646 
9647 
9649 
9668  string getDropConstraintSql(string cname, *hash opt);
9669 
9670 
9672 
9691  *string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref);
9692 
9693 
9694  private AbstractConstraint findDropConstraintUnlocked(string cname, reference rmv);
9695 
9696 
9698 
9716  AbstractConstraint dropConstraint(string cname, *reference sql);
9717 
9718 
9720 
9740  AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql);
9741 
9742 
9744 
9766  list getAddTriggerSql(string tname, string src, *hash topt, *hash opt);
9767 
9768 
9769  private AbstractTrigger addTriggerUnlocked(string tname, string src, *hash opt, *reference lsql);
9770 
9771 
9772  private AbstractTrigger addTriggerUnlockedIntern(string tname, string src, *hash opt, *reference lsql);
9773 
9774 
9776 
9794  AbstractTrigger dropTrigger(string tname, *reference sql);
9795 
9796 
9798 
9817  list getDropTriggerSql(string tname, *hash opt);
9818 
9819 
9820  private getAllConstraintsUnlocked(*hash opt);
9821 
9822 
9823  private checkUniqueConstraintName(string err, string cname);
9824 
9825 
9826  private checkUniqueConstraintNameValidateOptions(string err, string cname, hash ropt, reference opt);
9827 
9828 
9830  private validateColumnOptions(string cname, reference opt, bool nullable);
9831 
9832 
9834 
9852  AbstractColumn dropColumn(string cname, *reference lsql);
9853 
9854 
9856 
9875  list getDropColumnSql(string cname, *hash opt);
9876 
9877 
9879 
9889  insert(hash row, *reference sql);
9890 
9891 
9893 
9903  insertNoCommit(hash row, *reference sql);
9904 
9905 
9906  private insertNoCommitIntern(hash row, *reference sql, *hash opt);
9907 
9908 
9909  private hash getPlaceholdersAndValues(hash row);
9910 
9911 
9913 
9923  insert(hash row, *hash opt);
9924 
9925 
9927 
9937  insertNoCommit(hash row, *hash opt);
9938 
9939 
9941 
9959  int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql);
9960 
9961 
9963 
9981  int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql);
9982 
9983 
9984  private int insertFromSelectNoCommitIntern(list cols, AbstractTable source, *hash sh, *reference sql, *hash opt);
9985 
9986 
9988 
10006  int insertFromSelect(list cols, AbstractTable source, *hash sh, *hash opt);
10007 
10008 
10010 
10028  int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *hash opt);
10029 
10030 
10032 
10051 
10052 
10054 
10073 
10074 
10075  private int insertFromIteratorNoCommitIntern(Qore::AbstractIterator i, *hash opt);
10076 
10077 
10079 
10094  int upsert(hash row, int upsert_strategy = UpsertAuto);
10095 
10096 
10098 
10113  int upsertNoCommit(hash row, int upsert_strategy = UpsertAuto);
10114 
10115 
10117 
10137  code getUpsertClosure(hash example_row, int upsert_strategy = UpsertAuto);
10138 
10139 
10141 
10161  code getUpsertClosureWithValidation(hash example_row, int upsert_strategy = UpsertAuto);
10162 
10163 
10165 
10198 
10199 
10201 
10234 
10235 
10236  private *hash upsertFromIteratorNoCommitIntern(Qore::AbstractIterator i, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
10237 
10238 
10239  private *hash doDeleteOthersIntern(hash pkh, *hash opt);
10240 
10241 
10243 
10281  *hash upsertFromSelect(AbstractTable t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
10282 
10283 
10285 
10325  *hash upsertFromSelectNoCommit(AbstractTable t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
10326 
10327 
10329 
10367  *hash upsertFromSelect(Table t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
10368 
10369 
10371 
10411  *hash upsertFromSelectNoCommit(Table t, *hash sh, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
10412 
10413 
10415 
10426  softint rowCount();
10427 
10428 
10430 
10447  Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql);
10448 
10449 
10450  private Qore::SQL::SQLStatement getRowIteratorIntern(*hash sh, *reference sql, *hash opt);
10451 
10452 
10454 
10472 
10473 
10475 
10493  *hash selectRow(*hash sh, *reference sql);
10494 
10495 
10497 
10514  *list selectRows(*hash sh, *reference sql);
10515 
10516 
10518 
10535  *hash select(*hash sh, *reference sql);
10536 
10537 
10539 
10557  *hash selectRow(*hash sh, *hash opt);
10558 
10559 
10561 
10578  *list selectRows(*hash sh, *hash opt);
10579 
10580 
10582 
10599  *hash select(*hash sh, *hash opt);
10600 
10601 
10603 
10621  string getSelectSql(*hash sh, *reference args);
10622 
10623 
10624  *AbstractUniqueConstraint matchAnyUnique(list cols);
10625 
10626 
10627  string getSelectSqlIntern(*hash qh, reference args);
10628 
10629 
10630  string getSelectSqlUnlocked(*hash qh, reference args);
10631 
10632 
10633  string getSelectSqlUnlockedIntern(*hash qh, string from, reference args, *hash ch);
10634 
10635 
10636  private doForUpdate(reference sql);
10637 
10638 
10639  private string getSelectSqlName(*hash qh);
10640 
10641 
10642  private string getColumnExpressionIntern(any cvc, *hash jch, bool join, *hash ch);
10643 
10644 
10645  private string doColumnOperatorIntern(hash cvc, *hash jch, bool join, *hash ch);
10646 
10647 
10648  private string doColumnOperatorIntern(any cop, any arg, *string cve, hash cm, *hash jch, bool join, *hash ch);
10649 
10650 
10651  private string getColumnNameIntern(string cv, *hash jch, bool join, *hash ch);
10652 
10653 
10654  private getSelectWhereSqlUnlocked(reference sql, reference args, *hash qh, *hash jch, bool join = False, *hash ch);
10655 
10656 
10657  private *string getWhereClause(*hash cond, reference args, *string cprefix, *hash jch, bool join = False);
10658 
10659 
10660  private *string getWhereClause(list cond, reference args, *string cprefix, *hash jch, bool join = False);
10661 
10662 
10663  private *string getWhereClauseUnlocked(list cond, reference args, *string cprefix, *hash jch, bool join = False, *hash pch);
10664 
10665 
10666  private *string getWhereClauseUnlocked(*hash cond, reference args, *string cprefix, *hash jch, bool join = False, *hash pch);
10667 
10668 
10669  private *list getWhereClauseIntern(*hash cond, reference args, *string cprefix, *hash jch, bool join = False, *hash ch);
10670 
10671 
10672  private string doWhereExpressionIntern(string cn, any we, reference args, *hash jch, bool join = False, *hash ch);
10673 
10674 
10675  private list getOrderByListUnlocked(*hash qh, *hash jch, *hash ch);
10676 
10677 
10678  private doSelectOrderBySqlUnlocked(reference sql, reference args, *hash qh, *hash jch, *hash ch);
10679 
10680 
10682 
10696  int del(*hash cond, *reference sql);
10697 
10698 
10700 
10714  int delNoCommit(*hash cond, *reference sql);
10715 
10716 
10717  private int delNoCommitIntern(*hash cond, *reference sql, *hash opt);
10718 
10719 
10721 
10737  int update(hash set, *hash cond, *reference sql);
10738 
10739 
10741 
10757  int updateNoCommit(hash set, *hash cond, *reference sql);
10758 
10759 
10760  private int updateNoCommitIntern(hash set, *hash cond, *reference sql, *hash opt);
10761 
10762 
10764 
10778  int del(*hash cond, *hash opt);
10779 
10780 
10782 
10796  int delNoCommit(*hash cond, *hash opt);
10797 
10798 
10800 
10816  int update(hash set, *hash cond, *hash opt);
10817 
10818 
10820 
10836  int updateNoCommit(hash set, *hash cond, *hash opt);
10837 
10838 
10839  private string getUpdateExpression(string col, hash uh);
10840 
10841 
10842  private bool emptyDataUnlocked();
10843 
10844 
10845  private code getUpsertClosureUnlocked(hash row, int upsert_strategy = UpsertAuto);
10846 
10847 
10848  private code getUpsertInsertFirst(Columns cols, hash example_row);
10849 
10850 
10851  private code getUpsertUpdateFirst(Columns cols, hash example_row);
10852 
10853 
10854  private code getUpsertSelectFirst(Columns cols, hash example_row);
10855 
10856 
10857  private code getUpsertInsertOnly(Columns cols, hash example_row);
10858 
10859 
10860  private Columns getUpsertColumns(reference csrc);
10861 
10862 
10863  private string getUpsertSelectSql(hash row, Columns cols, reference updc);
10864 
10865 
10866  private string getUpsertInsertSql(hash row);
10867 
10868 
10869  private string getUpsertUpdateSql(hash row, Columns cols, reference updc);
10870 
10871 
10872  private softbool tryUpdate(string sql, hash row, Columns cols, list updc);
10873 
10874 
10875  private checkValue(string cname, string argname, reference val, string type);
10876 
10877 
10879 
10888  string getSqlFromList(list l);
10889 
10890 
10892 
10903  string getSqlValue(any v);
10904 
10905 
10907  string getName();
10908 
10909 
10911 
10918  cache(*hash opts);
10919 
10920 
10922 
10927  clear();
10928 
10929 
10931 
10938  Columns describe();
10939 
10940 
10942 
10951 
10952 
10954 
10964 
10965 
10966  *AbstractUniqueConstraint findUniqueConstraintUnlocked(string name);
10967 
10968 
10970 
10979  Indexes getIndexes();
10980 
10981 
10984 
10985 
10988 
10989 
10991 
11001 
11002 
11004 
11022  string getRenameSql(string new_name, *hash opt);
11023 
11024 
11026 
11035  string getCreateSqlString(*hash opt);
11036 
11037 
11039 
11048  list getCreateSql(*hash opt);
11049 
11050 
11052 
11063  string getCreateTableSql(*hash opt);
11064 
11065 
11067 
11071  bool checkExistence();
11072 
11073 
11074  private *hash getCheckOmissionOptions(*softlist ol, string err);
11075 
11076 
11078 
11094 
11095 
11096  private list getAlignSqlUnlocked(AbstractTable t, *hash opt);
11097 
11098 
11099  private renameIndexUnlocked(AbstractIndex ix, string new_name);
11100 
11101 
11103 
11116  string getAlignSqlString(AbstractTable t, *hash opt);
11117 
11118 
11120 
11132  *list getCreateIndexesSql(*hash opt, bool cache = True);
11133 
11134 
11136 
11148  *string getCreatePrimaryKeySql(*hash opt, bool cache = True);
11149 
11150 
11152 
11165 
11166 
11168 
11182  *list getCreateConstraintsSql(*hash opt, bool cache = True);
11183 
11184 
11186 
11198  *list getCreateMiscSql(*hash opt, bool cache = True);
11199 
11200 
11202 
11216  *list getCreateTriggersSql(*hash opt, bool cache = True);
11217 
11218 
11220 
11227  *hash find(any id);
11228 
11229 
11231 
11242  *list find(list ids);
11243 
11244 
11245  private string getPrimaryKeyColumn();
11246 
11247 
11249 
11262  *hash find(hash row);
11263 
11264 
11266 
11279  *hash findSingle(*hash cond);
11280 
11281 
11283 
11296  *list findAll(*hash cond);
11297 
11298 
11300  string getSqlName();
11301 
11302 
11304  string getColumnSqlName(string col);
11305 
11306 
11308  list getColumnSqlNames(softlist cols);
11309 
11310 
11312 
11314  private hash getTableOptions();
11315 
11316 
11318 
11321 
11322 
11324 
11326  private hash getConstraintOptions();
11327 
11328 
11330 
11332  private hash getCacheOptions();
11333 
11334 
11336 
11338  private hash getTableCreationOptions();
11339 
11340 
11342 
11344  private hash getAlignTableOptions();
11345 
11346 
11348 
11351 
11352 
11354 
11356  private hash getColumnOptions();
11357 
11358 
11360 
11362  private hash getColumnDescOptions();
11363 
11364 
11366 
11368  private hash getTableColumnDescOptions();
11369 
11370 
11372 
11374  private hash getIndexOptions();
11375 
11376 
11378 
11380  private hash getTriggerOptions();
11381 
11382 
11384 
11386  private hash getSelectOptions();
11387 
11388 
11390 
11392  private hash getUpsertOptions();
11393 
11394 
11396 
11398  private hash getInsertOptions();
11399 
11400 
11402 
11404  private hash getSqlDataCallbackOptions();
11405 
11406 
11408 
11410  private hash getWhereOperatorMap();
11411 
11412 
11414 
11416  private hash getColumnOperatorMap();
11417 
11418 
11420 
11422  private hash getInsertOperatorMap();
11423 
11424 
11426 
11428  private hash getUpdateOperatorMap();
11429 
11430 
11431  private string getCreateTableSqlUnlocked(*hash opt);
11432 
11433 
11434  private *list getCreateIndexesSqlUnlocked(*hash opt, bool cache = True);
11435 
11436 
11437  private *string getCreatePrimaryKeySqlUnlocked(*hash opt, bool cache = True);
11438 
11439 
11440  private *list getCreateConstraintsSqlUnlocked(*hash opt, bool cache = True);
11441 
11442 
11443  private *list getCreateForeignConstraintsSqlUnlocked(*hash opt, bool cache = True);
11444 
11445 
11446  private *list getCreateMiscSqlUnlocked(*hash opt, bool cache = True);
11447 
11448 
11449  private *list getCreateTriggersSqlUnlocked(*hash opt, bool cache = True);
11450 
11451 
11452  private list getCreateSqlUnlocked(*hash opt, bool cache = True);
11453 
11454 
11455  private cacheUnlocked(*hash opt);
11456 
11457 
11458  private any execData(*hash opt, string sql, *list args);
11459 
11460 
11461  private execData(SQLStatement stmt, *hash opt, *list args);
11462 
11463 
11464  static AbstractTable getTable(AbstractDatasource nds, string nname, *hash opts);
11465 
11466  static AbstractTable getTable(string dsstr, string nname, *hash opts);
11467 
11468  static AbstractTable getTable(hash dsh, string nname, *hash opts);
11469 
11470  private getColumnsUnlocked();
11471 
11472 
11473  private getPrimaryKeyUnlocked();
11474 
11475 
11476  // also loads primary key and constraints (for unique constraints)
11477  private getIndexesUnlocked();
11478 
11479 
11480  private getForeignConstraintsUnlocked(*hash opt);
11481 
11482 
11483  private addSourceConstraint(string table_name, AbstractForeignConstraint fk);
11484 
11485 
11486  private getConstraintsUnlocked();
11487 
11488 
11489  private getTriggersUnlocked();
11490 
11491 
11492  private softlist getDropSqlImpl();
11493 
11494 
11495  private string getTruncateSqlImpl();
11496 
11497 
11499  private any tryExecArgsImpl(string sql, *softlist args);
11500 
11501 
11503  private any tryExecRawImpl(string sql);
11504 
11505 
11507  private clearImpl();
11508 
11509 
11510  private preSetupTableImpl(reference desc, *hash opt);
11511 
11512 
11513  private abstract bool emptyImpl();
11514 
11516  private abstract *string getSqlValueImpl(any v);
11517 
11519 
11522  private abstract bool checkExistenceImpl();
11523 
11525  private abstract bool supportsTablespacesImpl();
11526 
11528  private abstract bool constraintsLinkedToIndexesImpl();
11529 
11531  private abstract bool uniqueIndexCreatesConstraintImpl();
11532 
11533  private abstract setupTableImpl(hash desc, *hash opt);
11534 
11535  private abstract Columns describeImpl();
11536  private abstract AbstractPrimaryKey getPrimaryKeyImpl();
11537  private abstract Indexes getIndexesImpl();
11538  private abstract ForeignConstraints getForeignConstraintsImpl(*hash opt);
11539  private abstract Constraints getConstraintsImpl();
11540  private abstract Triggers getTriggersImpl();
11541 
11542  private abstract string getCreateTableSqlImpl(*hash opt);
11543  private abstract *list getCreateMiscSqlImpl(*hash opt, bool cache);
11544  private abstract string getCreateSqlImpl(list l);
11545  private abstract string getRenameSqlImpl(string new_name);
11546  private abstract *list getAlignSqlImpl(AbstractTable t, *hash opt);
11547 
11548  private abstract AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
11549  private abstract AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
11550  private abstract AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
11551  private abstract AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
11552  private abstract AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
11553  private abstract AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
11554 
11555  private abstract AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
11556 
11558  private abstract bool tryInsertImpl(string sql, hash row);
11559 
11561  private abstract hash getQoreTypeMapImpl();
11562 
11564  private abstract hash getTypeMapImpl();
11565 
11567  private abstract doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch);
11568 
11570  private abstract doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh);
11571 
11573  private abstract copyImpl(AbstractTable old);
11574  };
11575 
11576 /*
11577  public class Sqlite3Table inherits AbstractTable {
11578 
11579  public {
11580  const Sqlite3TypeMap = (
11581  "INTEGER": ("qore": "integer",),
11582  "NUMERIC": ("qore": "number",),
11583  "TEXT": ("qore": "string",),
11584  "BLOB": ("qore": "binary",),
11585  "NONE": ("qore": "any",),
11586  "REAL": ("qore": "float",),
11587  );
11588 
11589  const QoreTypeMap = (
11590  "integer": "INTEGER",
11591  "float": "NUMBER",
11592  "number": "NUMBER",
11593  "string": "VARCHAR2",
11594  #"date": "TIMESTAMP",
11595  "binary": "BLOB",
11596  );
11597  }
11598 
11599  constructor(AbstractDatasource nds, string nname, *hash opts) : AbstractTable(nds, nname, opts) {
11600  }
11601 
11602  private hash describeImpl() {
11603  hash rv;
11604 
11605  # NOTE: sqlite3's pragmas cannot use %v binding
11606 
11607  # table info - PK is part of the table description
11608  hash tableInfo = ds.select("pragma table_info(%s)", name);
11609  context(tableInfo) {
11610  rv.columns{%name} = (
11611  "native_type" : %type,
11612  "qore_type" : Sqlite3TypeMap{%type}.qore,
11613  "size" : NOTHING,
11614  "nullable" : %notnull == 1 ? NOTHING : "YES",
11615  );
11616  if (%pk)
11617  rv.primary_key{%name} = True;
11618  }
11619 
11620  # get index description
11621  hash indexes = ds.select("pragma index_list(%s)", name);
11622  context(indexes) {
11623  rv.indexes{%name}.unique = %unique == 0 ? False : True;
11624  hash indexColumns = ds.select("pragma index_info(%s)", %name);
11625  string columnName = %name;
11626  context (indexColumns) {
11627  rv.indexes{columnName}.columns{%name} = True;
11628  }
11629  }
11630 
11631  # TODO/FIXME: FKs
11632 
11633  return rv;
11634  }
11635  }
11636 */
11637 }
11638 
abstract string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
const ActionMap
maps from action codes to action descriptions
Definition: SqlUtil.qm.dox.h:5095
list getAlignSql(AbstractTable table, *hash opt)
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure a...
string name
the name of the constraint
Definition: SqlUtil.qm.dox.h:4014
string getRenameColumnSql(string old_name, string new_name, *hash opt)
gets an SQL string that can be used to rename an existing column in the table
private validateHashKeysForWhitespaces(any node)
Check input node for all hash keys - if it contains a key with whitespace in the beginning or at the ...
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_max)
creates the object from the arguments
int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql)
inserts rows into a table based on a select statement from another table (which must be using the sam...
hash cop_avg(any column)
returns a hash for the "avg" operator; returns average column values
string getElementName()
returns "column" since this object stores column objects
softlist getDropSql(*hash opt)
returns the sql required to drop the table; reimplement in subclasses if necessary ...
bool hasColumn(string cname)
returns True if the constraint references the named column
constructor()
creates an empty object
*string index
the index supporting the constraint
Definition: SqlUtil.qm.dox.h:4102
AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql)
adds an index to the table; if the table is already known to be in the database, then it is added in ...
createNoCommit(*hash opt)
creates the table with all associated properties (indexes, constraints, etc) without any transaction ...
const SelectOptions
default select options
Definition: SqlUtil.qm.dox.h:8432
string getDropSql()
returns a string that can be used to drop the function from the database
Constraints getConstraints()
returns a Constraints object describing the non-foreign constraints on the table
private hash getCacheOptions()
returns the cache options for this driver
*hash find(any id)
finds a row in the table with the given primary key value; if no row matches the primary key value pa...
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:4283
hash uop_lower(*hash nest)
returns a hash for the "lower" operator with the given argument; returns a column value in lower case...
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
const COP_SEQ
to return the value of a sequence
Definition: SqlUtil.qm.dox.h:1781
Qore::AbstractIterator pairIterator()
Returns a HashPairIterator object for the contained hash.
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
const Hash
const UpsertAuto
Upsert option: if the target table is empty, use UpsertInsertFirst, otherwise use UpsertUpdateFirst...
Definition: SqlUtil.qm.dox.h:8608
string getTruncateSql(*hash opt)
gets the SQL that can be used to truncate the table
list getAlignProcedureSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a stored procedure in the database to the st...
string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt)
returns an SQL string that can be used to add an index to the table
const String
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
hash op_cge(string arg)
returns a hash for the ">=" operator with the given argument for use in where clauses when comparing ...
const DefaultIopMap
a hash of default insert operator descriptions
Definition: SqlUtil.qm.dox.h:3094
int updateNoCommit(hash set, *hash cond, *reference sql)
updates rows in the table matching an optional condition and returns the count of rows updated; no tr...
private hash getTriggerOptions()
returns the trigger options for this driver
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:3406
*list getCreateTriggersSql(*hash opt)
returns a list of SQL strings that could be used to create triggers on the table or NOTHING if there ...
bool inDb()
returns True if the table has been read from or created in the database, False if not ...
const TableOmissionOptions
alignment omission options
Definition: SqlUtil.qm.dox.h:8449
string getDropSql()
returns a string that can be used to drop the sequence from the database
list getDropSchemaSql(hash schema_hash, *hash opt)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
copy(AbstractHashContainer old)
creates a "deep copy" of the object
hash cop_append(any column, string arg)
returns a hash for the "append" operator with the given argument
hash uop_append(string arg, *hash nest)
returns a hash for the "append" or concatenate operator with the given argument
string sprintf(string fmt,...)
constructor(*hash nh)
creates the object with the hash argument passed
Qore::ListIterator iterator()
Returns a ListIterator object for the contained list.
private hash getDatabaseOptions()
override in subclasses to return driver-specific options
const AC_Unchanged
used when an existing object matches the template and no changes are made
Definition: SqlUtil.qm.dox.h:5058
string getElementName()
must return the name of the contained element
bool equal(ForeignConstraintTarget targ)
returns True if the argument is equal to the current object, False if not
AbstractColumn modifyColumn(string cname, hash opt, bool nullable=True, *reference lsql)
modifies an existing column in the table; if the table is already known to be in the database...
bool dropProcedureIfExists(string name, *hash opt)
drops the given procedure if it exists; returns True if the procedure was dropped, False if not
const OP_IN
the SQL "in" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2700
bool checkExistence()
returns True if the table exists in the database, False if not
*hash getHash()
returns the hash contained by this object
the base abstract class for the table implementation
Definition: SqlUtil.qm.dox.h:8371
const DefaultCopMap
a hash of default column operator descriptions
Definition: SqlUtil.qm.dox.h:1784
bool equal(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
any methodGate(string meth)
executes a method on the contained AbstractTable object
hash iop_seq(string arg)
returns a hash for retrieving the value of the given sequence in insert queries
bool equalExceptName(AbstractIndex ix)
returns True if the argument is equal to the current index with the exception of the name...
const VARCHAR
specifies a VARCHAR column (equivalent to Qore::Type::String)
Definition: SqlUtil.qm.dox.h:1642
AbstractFunction memberGate(string k)
returns the AbstractFunction object corresponding to the key given or throws a KEY-ERROR exception ...
*AbstractUniqueConstraint findUniqueConstraint(string name)
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary...
hash uop_upper(*hash nest)
returns a hash for the "upper" operator with the given argument; returns a column value in upper case...
list getAlignFunctionSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a function in the database to the function d...
const ForeignConstraintOptions
default foreign constraint options
Definition: SqlUtil.qm.dox.h:8409
string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt)
returns the SQL that can be used to add a primary key to the table
int delNoCommit(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; no transactio...
const ColumnOptions
Column options; this is currently empty and can be extended in database-specific modules.
Definition: SqlUtil.qm.dox.h:8532
the table container class stores a collection of tables in a schema
Definition: SqlUtil.qm.dox.h:3495
*list getCreateForeignConstraintsSql(*hash opt)
returns a list of SQL strings that could be used to create foreign constraints on the table or NOTHIN...
Qore::AbstractIterator getUniqueConstraintIterator()
returns an iterator for all unique constraints on the table (including the primary key if any) ...
constructor(string n)
creates the object and sets its name
bool updatable
Flag showing if is the view updatable with DML commands.
Definition: SqlUtil.qm.dox.h:4326
private hash getCreationOptions()
override in subclasses to return driver-specific options
drop(*hash opt)
drops the table from the database; releases the transaction lock after dropping the table ...
*string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref)
gets the SQL that can be used to drop a constraint from the table if it exists, otherwise returns NOT...
private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
string getAddPrimaryKeySql(string pkname, softlist cols, *hash pkopt, *hash opt)
returns the SQL that can be used to add a primary key to the table
hash op_between(any l, any r)
returns a hash for the "between" operator with the given arguments, neither of which can be NULL or N...
abstract string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
const UpsertResultLetterMap
maps upsert result codes to single letter symbols
Definition: SqlUtil.qm.dox.h:8683
const UpsertStrategyMap
hash mapping upsert strategy codes to a text description
Definition: SqlUtil.qm.dox.h:8620
hash make_iop(string iop, any arg)
returns a hash with _iop and arg keys
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
date now_us()
AbstractIndex take(string k)
removes the given key from the contained hash and returns the value
int update(hash set, *hash cond, *reference sql)
updates rows in the table matching an optional condition and returns the count of rows updated; the t...
abstract string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
abstract list getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
const DropSchemaOptions
default generic drop schema options
Definition: SqlUtil.qm.dox.h:5164
string getDropIndexSql(string iname, *hash opt)
gets the SQL that can be used to drop an index from the table
hash uop_prepend(string arg, *hash nest)
returns a hash for the "prepend" operator with the given argument
string getCreateTableSql(*hash opt)
returns an SQL string that could be used to create the basic table structure without indexes and cons...
const SchemaDescriptionOptions
default generic schema description keys
Definition: SqlUtil.qm.dox.h:5179
const UR_Inserted
row was inserted
Definition: SqlUtil.qm.dox.h:8645
constructor(string t, Columns c)
creates the object and sets the target table name and the target columns
constructor(string n_name, string n_src)
creates the object from the arguments
string getDriverName()
returns the database driver name
hash op_in()
returns a hash for the "in" operator with all arguments passed to the function; for use in where clau...
cache(*hash opts)
reads in all attributes of the table from the database
string printf(string fmt,...)
const OP_BETWEEN
the SQL "between" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2695
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view cannot be found ...
int upsert(hash row, int upsert_strategy=UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
abstract any take(string k)
removes the given key from the contained hash and returns the value
const DatabaseOptions
database options
Definition: SqlUtil.qm.dox.h:5025
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database; if disabli...
private hash getIndexOptions()
returns the index options for this driver
the abstract base class for index information
Definition: SqlUtil.qm.dox.h:3891
*AbstractUniqueConstraint findEqualUniqueConstraint(AbstractUniqueConstraint uk)
finds a unique constraint with the same columns as the unique constraint passed
hash sourceConstraints
a hash of ForeignConstraintSources, keyed by table name, the value is a hash of foreign constraints k...
Definition: SqlUtil.qm.dox.h:4099
*AbstractUniqueConstraint getSupportingConstraint()
returns the supporting constraint, if any
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
*hash upsertFromSelectNoCommit(AbstractTable t, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
this method upserts or merges data from the given foreign table and select option hash into the curre...
Triggers getTriggers()
returns an object of class Triggers describing the triggers on the table
add(string k, AbstractColumn val)
adds the given value to the hash with the given key name
const COP_OVER
the SQL "over" clause
Definition: SqlUtil.qm.dox.h:1736
foreign constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:4176
const UpsertResultDescriptionMap
hash mapping upsert descriptions to codes
Definition: SqlUtil.qm.dox.h:8674
Columns columns
an object of class Columns giving the source table that make up the constraint
Definition: SqlUtil.qm.dox.h:4250
const UR_Deleted
row was deleted (only possible with batch upsert methods such as Table::upsertFromIterator() where up...
Definition: SqlUtil.qm.dox.h:8657
list listTables()
returns a list of string table names in the database
bool dropProcedureIfExists(string name, *hash opt)
drops the given procedure if it exists; returns True if the procedure was dropped, False if not
hash op_ne(any arg)
returns a hash for the "!=" or "<>" operator with the given argument for use in where clauses when co...
bool dropFunctionIfExists(string name, *hash opt)
drops the given function if it exists; returns True if the function was dropped, False if not ...
constructor(string n, *hash c, *string n_index)
creates the object from the name an a hash of column information
abstract private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
hash make_jop(string jop, AbstractTable table, *string alias, *hash jcols, *hash cond, *string ta, *hash opt)
returns a hash keyed with the table name assigned to a hash with jop, table, jcols, cond, alias, and ta keys
clearIndex()
clears any index base for the constraint
AbstractForeignConstraint removeForeignConstraint(string cname)
removes the named foreign constraint from the table; no SQL is executed in any case, only the named foreign constraint is removed from the table definition
bool hasColumn(string cname)
returns True if the constraint references the named column
const OP_NE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2655
AbstractIndex dropIndex(string iname, *reference sql)
drops the given index from the table; if the table is known to be in the database already...
AbstractColumn dropColumn(string cname, *reference lsql)
drops a column from the table
list listSequences()
returns a list of string sequence names in the database
setSupportingConstraint()
clears the supporting constraint
hash cop_as(any column, string arg)
returns a hash for the "as" operator with the given argument
private hash getSchemaDescriptionOptions()
override in subclasses to return driver-specific options
string getType()
returns the type of object
any methodGate(string meth)
executes a method on the contained AbstractDatabase object
string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt)
returns an SQL string that can be used to add a check constraint to the table
abstract softlist getRenameSql(string new_name)
returns a list with command(s) that can be used to rename the view in the database ...
hash cop_year_month(any column)
returns a hash for the "year_month" operator with the given argument
list getAlignSql(AbstractTable t, *hash opt)
accepts an AbstractTable argument and returns a list of SQL strings required to align the structure a...
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
list getDropTriggerSql(string tname, *hash opt)
returns SQL that can be used to drop the given trigger from the table
private constructor(AbstractDatasource nds, string nname, *hash nopts)
creates the object; private constructor
truncate()
truncates all the table data; releases the transaction lock after executing
string name
the name of the object
Definition: SqlUtil.qm.dox.h:4352
string getAlignSqlString(AbstractTable t, *hash opt)
accepts an AbstractTable argument and returns an SQL string that could be executed to align the struc...
AbstractColumn dropColumn(string cname, *reference lsql)
drops a column from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
a class describing a foreign constraint target
Definition: SqlUtil.qm.dox.h:4223
string getAlignSqlString(AbstractTable table, *hash opt)
accepts an AbstractTable argument and returns an SQL string that could be executed to align the struc...
*list getCreateIndexesSql(*hash opt, bool cache=True)
returns a list of SQL strings that could be used to create indexes on the table or NOTHING if there a...
*string getDropFunctionSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given function if it exists or NOTHING if the named function does...
*string qore_type
the equivalent qore type name of the column if known
Definition: SqlUtil.qm.dox.h:3735
add(string k, AbstractConstraint val)
adds the given value to the hash with the given key name
hash op_gt(any arg)
returns a hash for the ">" operator with the given argument for use in where clauses when comparing c...
Constraints getConstraints()
returns a Constraints object describing non-foreign constraints on the table
the base class to use to extend AbstractColumn to implement numeric columns
Definition: SqlUtil.qm.dox.h:3831
AbstractIndex renameIndex(string old_name, string new_name, reference sql)
renames an existing index; if the table is already known to be in the database, then the changes are ...
list getRecreateSql(AbstractDatasource ds, string table_name, *hash opt)
returns a list of strings to drop and recreate the current index; if there are dependent constraints...
const AC_Create
used when a new object is created
Definition: SqlUtil.qm.dox.h:5061
add(string k, AbstractFunction val)
adds the given value to the hash with the given key name
const True
string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt)
returns an SQL string that can be used to add a unique constraint to the table
AbstractTrigger memberGate(string k)
returns the AbstractTrigger object corresponding to the key given or throws a KEY-ERROR exception ...
list listViews()
returns a list of string view names in the database
softint rowCount()
returns the number of rows in the table
*string getCreatePrimaryKeySql(*hash opt)
returns an SQL string that could be used to create the primary key on the table
abstract private hash getQoreTypeMapImpl()
returns the qore type -> column type map
list keys()
Returns a list of key names of the contained hash.
AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql)
adds a foreign constraint to the table; if the table is already known to be in the database...
const JopMap
a hash of valid join operators
Definition: SqlUtil.qm.dox.h:2317
hash make_op(string op, any arg)
returns a hash with op and arg keys
const SZ_MAND
the data type takes a mandatory size parameter
Definition: SqlUtil.qm.dox.h:1665
const OP_GT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2645
const CHAR
specifies a CHAR column
Definition: SqlUtil.qm.dox.h:1648
hash op_clt(string arg)
returns a hash for the "<" operator with the given argument for use in where clauses when comparing t...
const COP_AVG
to return the average value
Definition: SqlUtil.qm.dox.h:1726
const DB_SEQUENCES
Feature: sequences.
Definition: SqlUtil.qm.dox.h:1628
const DB_MVIEWS
Feature: materialized views/snapshots.
Definition: SqlUtil.qm.dox.h:1622
int del(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; the transacti...
list getAddTriggerSql(string tname, string src, *hash topt, *hash opt)
returns a list of SQL strings that can be used to add a trigger to the table
private clearImpl()
clears any driver-specific table information
const JOP_LEFT
for left outer joins
Definition: SqlUtil.qm.dox.h:2309
base class for sequences
Definition: SqlUtil.qm.dox.h:4278
*list getCreateTriggersSql(*hash opt, bool cache=True)
returns a list of SQL strings that could be used to create triggers on the table or NOTHING if there ...
list listFunctions()
returns a list of string function names in the database
hash op_cgt(string arg)
returns a hash for the ">" operator with the given argument for use in where clauses when comparing t...
private hash getColumnOperatorMap()
returns the column operator map for this object
string getElementName()
must return the name of the contained element
add(any val)
adds the given value to the list
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
abstract string getElementName()
must return the name of the contained element
int updateNoCommit(hash set, *hash cond, *reference sql)
updates rows in the table matching an optional condition and returns the count of rows updated; no tr...
Columns subset(softlist l)
returns a subset of the current columns according to the list argument
nothing flush()
bool nullable
True if the column can hold a NULL value, False if not
Definition: SqlUtil.qm.dox.h:3741
hash cop_min(any column)
returns a hash for the "min" operator; returns minimum column values
AbstractPrimaryKey addPrimaryKey(string pkname, softlist cols, *hash opt, *reference sql)
adds a primary key to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
const UpsertOptions
default upsert option keys
Definition: SqlUtil.qm.dox.h:8548
number number(softnumber n)
const COP_DISTINCT
to return distinct values
Definition: SqlUtil.qm.dox.h:1711
const COP_YEAR_HOUR
to return a date value with year to hextern information
Definition: SqlUtil.qm.dox.h:1776
const CacheOptions
default cache options
Definition: SqlUtil.qm.dox.h:8401
AbstractFunction makeFunction(string name, string src, *hash opts)
creates a database-specific AbstractFunction object corresponding to the arguments ...
Columns describe()
returns an object of class Columns describing the table
list getAddTriggerSql(string tname, string src, *hash topt, *hash opt)
returns a list of SQL strings that can be used to add a trigger to the table
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found ...
*list getDropAllForeignConstraintsOnTableSql(string name, *hash opt)
returns a list of SQL strings that can be used to drop all the foreign constraints on a particular ta...
int update(hash set, *hash cond, *reference sql)
updates rows in the table matching an optional condition and returns the count of rows updated; the t...
ForeignConstraints foreignConstraints
foreign constraints description
Definition: SqlUtil.qm.dox.h:8703
bool native_case
native case option
Definition: SqlUtil.qm.dox.h:8709
*AbstractUniqueConstraint constraint
the AbstractUniqueConstraint that this index supports, if any
Definition: SqlUtil.qm.dox.h:3908
string getTruncateSql(*hash opt)
gets the SQL that can be used to truncate the table
AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql)
renames an existing constraint; this can be any constraint on the table, a primary key...
list getDropAllConstraintsAndIndexesOnColumnSql(string cname, *hash opt)
gets a list of SQL strings to drop all constraints and indexes with the given column name; if the col...
private hash getUpdateOperatorMap()
returns the update operator map for this object
bool dropSequenceIfExists(string name, *hash opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not ...
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql)
returns an SQLStatement object that will iterate the results of a select statement matching the argum...
string getSelectSql(*hash sh, *reference args)
returns the SQL string to be executed corresponding to the argument hash with an output parameter for...
list getDropPrimaryKeySql(*hash opt)
gets a list of SQL strings that can be used to drop the primary key from the table ...
AbstractFunction take(string k)
removes the given key from the contained hash and returns the value
hash op_cne(string arg)
returns a hash for the "!=" or "<>" operator with the given argument for use in where clauses when co...
create(*hash opt)
creates the table in the database; releases the transaction lock after creating the table ...
AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql)
adds a trigger to the table; if the table is already known to be in the database, then it is added in...
const List
base class for abstract SqlUtil classes
Definition: SqlUtil.qm.dox.h:4964
const CacheOptions
generic cache options
Definition: SqlUtil.qm.dox.h:5033
const UpsertUpdateFirst
Upsert option: update first, if the update fails, then insert.
Definition: SqlUtil.qm.dox.h:8592
private constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
abstract private bool tryInsertImpl(string sql, hash row)
tries to insert a row, if there is a duplicate key, then it returns False, if successful, returns True
int del(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; the transacti...
list getAddColumnSql(string cname, hash copt, bool nullable=True, *hash opt)
returns a list of SQL strings that can be use to add a column to the table
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
const NULL
const AC_Modify
used when an object is modified in place
Definition: SqlUtil.qm.dox.h:5070
bool equal(Columns cols)
returns True if the argument has the same columns in the same order as the current object...
*hash upsertFromSelectNoCommit(AbstractTable src, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
this method upserts or merges data from the given foreign table and select option hash into the curre...
create(*hash opt)
creates the table in the database; releases the transaction lock after creating the table ...
const OP_CNE
the SQL not equals operator (!= or <>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2685
any memberGate(string k)
returns the value of the given key in the contained hash if it exists, otherwise throws a KEY-ERROR e...
represents a database; this class embeds an AbstractDatabase object that is created automatically in ...
Definition: SqlUtil.qm.dox.h:4515
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
abstract private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh)
processes a string for use in SQL select statements when there is a "limit" argument, but no "orderby" or "offset" arguments
constructor(AbstractDatasource ds, string name, *hash opts)
creates the Table object
private hash getSqlDataCallbackOptions()
returns the sql data operation callback options for this driver
const OP_CGT
the SQL greater than operator (>) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2675
bool dropSequenceIfExists(string name, *hash opt)
drops the given sequence if it exists; returns True if the sequence was dropped, False if not ...
the base class for foreign key constraint information
Definition: SqlUtil.qm.dox.h:4245
hash op_like(string str)
returns a hash for the "like" operator with the given argument for use in where clauses ...
ForeignConstraintTarget target
a ForeignConstraintTarget object to describe the target table and columns
Definition: SqlUtil.qm.dox.h:4253
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
const False
bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
constructor(string n, string n_src)
creates the object and sets its name and the check clause source
AbstractConstraint memberGate(string k)
returns the AbstractConstraint object corresponding to the key given or throws a KEY-ERROR exception ...
Mutex l()
mutex for atomic actions
abstract private copyImpl(AbstractTable old)
db-specific copy actions
string getAddUniqueConstraintSql(string cname, softlist cols, *hash ukopt, *hash opt)
returns an SQL string that can be used to add a unique constraint to the table
const NothingType
hash op_lt(any arg)
returns a hash for the "<" operator with the given argument for use in where clauses when comparing c...
abstract string getCreateSql(string table_name, *hash opts)
returns a string that can be used to create the constraint in the database
hash op_le(any arg)
returns a hash for the "<=" operator with the given argument for use in where clauses when comparing ...
*AbstractView getView(string name)
returns an AbstractView argument for the given view name or NOTHING if the view
AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql)
adds a check constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
int scale
the scale for numeric columns
Definition: SqlUtil.qm.dox.h:3836
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
abstract class for check constraints
Definition: SqlUtil.qm.dox.h:4067
AbstractConstraint renameConstraint(string old_name, string new_name, reference lsql)
renames an existing constraint; this can be any constraint on the table, a primary key...
bool emptyData()
returns True if the table has no data rows, False if not
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
const AC_Drop
used when an object is dropped
Definition: SqlUtil.qm.dox.h:5064
bool equal(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
constructor(string n, bool u, hash c)
creates the object from the name, a unique flag, and a hash of column information ...
const COP_COUNT
to return the row count
Definition: SqlUtil.qm.dox.h:1731
createNoCommit(*hash opt)
creates the table with all associated properties (indexes, constraints, etc) without any transaction ...
list list(...)
list getCreateSql(*hash opt)
returns a list of SQL strings that could be used to create the table and all known properties of the ...
int getNextSequenceValue(string name)
returns the next value in the given sequence
const OP_CEQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2690
abstract container class that throws an exception if an unknown key is accessed
Definition: SqlUtil.qm.dox.h:3128
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
the SqlUtil namespace contains all the objects in the SqlUtil module
Definition: SqlUtil.qm.dox.h:1611
bool empty()
returns True if the table has no definitions, False if not
hash cop_distinct(any column)
returns a hash for the "distinct" operator with the given argument; returns distinct column values ...
Qore::ListIterator sequenceIterator()
returns an iterator listing the string sequence names in the database
const ActionLetterMap
maps from action codes to action letter codes
Definition: SqlUtil.qm.dox.h:5127
string name
the table's name
Definition: SqlUtil.qm.dox.h:8695
abstract private bool supportsTablespacesImpl()
returns True if the database support tablespaces
bool supportsPackages()
returns True if the database supports packages
string getAddIndexSql(string iname, bool unique, softlist cols, *hash ixopt, *hash opt)
returns an SQL string that can be used to add an index to the table
trigger container class that throws an exception if an unknown trigger is accessed ...
Definition: SqlUtil.qm.dox.h:4467
renameSourceConstraintTable(string old_name, string new_name)
renames a table in a source constraint
AbstractTrigger dropTrigger(string tname, *reference sql)
drops the given trigger from the table; if the table is known to be in the database already...
const DefaultUopMap
a hash of valid update operators
Definition: SqlUtil.qm.dox.h:2191
int index(softstring str, softstring substr, softint pos=0)
string src
the source of the check clause
Definition: SqlUtil.qm.dox.h:4072
string getDatasourceDesc()
returns a descriptive string for the datasource
Indexes indexes
index descriptions
Definition: SqlUtil.qm.dox.h:8701
*string getDropSequenceSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given sequence if it exists or NOTHING if the named sequence does...
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
private hash getDropSchemaOptions()
override in subclasses to return driver-specific options
const DB_PACKAGES
Feature: packages.
Definition: SqlUtil.qm.dox.h:1624
AbstractColumn take(string k)
removes the given key from the contained hash and returns the value
*hash upsertFromSelect(AbstractTable src, *hash sh, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
this method upserts or merges data from the given foreign table and select option hash into the curre...
list listProcedures()
returns a list of string procedure names in the database
const COP_UPPER
to return column value in upper case
Definition: SqlUtil.qm.dox.h:1701
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
const COP_PLUS
the SQL "minus" operator
Definition: SqlUtil.qm.dox.h:1746
private hash getSelectOptions()
returns the select options for this driver
const Boolean
abstract private bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
hash cop_minus(any column1, any column2)
returns a hash for the "-" operator with the given arguments
cache(*hash opts)
reads in all attributes of the table from the database
const UR_Verified
row was updated unconditionally (not returned with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8648
abstract private bool supportsSequencesImpl()
returns True if the database supports sequences
clear()
purges the current table definition
const OP_GE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2650
index container class that throws an exception if an unknown index is accessed
Definition: SqlUtil.qm.dox.h:3849
private validateColumnOptions(string cname, reference opt, bool nullable)
validates column options
const SZ_NUM
the data type is numeric so takes an optional precision and scale
Definition: SqlUtil.qm.dox.h:1671
abstract private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql)
adds a unique constraint to the table; if the table is known to be in the database already...
const TableOptions
table options
Definition: SqlUtil.qm.dox.h:8380
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
const AC_Rename
used when an object is renamed
Definition: SqlUtil.qm.dox.h:5067
Indexes getIndexes()
returns an object of class Indexes describing the indexes on the table
abstract bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
private hash getTableColumnDescOptions()
returns the table column description options for this driver
*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...
list getAlignSql(hash schema_hash, *hash opt, *Tables table_cache)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
ForeignConstraints getForeignConstraints(*hash opt)
returns a ForeignConstraints object describing the foreign constraints that the table has on other ta...
string getRenameSql(string new_name, *hash opt)
returns an SQL string that could be used to rename the table in the database
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
*string def_val
default value for column
Definition: SqlUtil.qm.dox.h:3744
int insertFromIterator(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
string getCreateSql(AbstractTable t)
returns an sql string that can be used to add the column to a table
AbstractPrimaryKey primaryKey
primary key description
Definition: SqlUtil.qm.dox.h:8699
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
insertNoCommit(hash row, *reference sql)
inserts a row into the table without any transaction management; a transaction will be in progress af...
AbstractPrimaryKey addPrimaryKey(string cname, softlist cols, *hash opt, *reference sql)
adds a primary key to the table; if the table already exists, then it is added in the database also i...
hash cop_plus(any column1, any column2)
returns a hash for the "+" operator with the given arguments
string getAddCheckConstraintSql(string cname, string src, *hash copt, *hash opt)
returns an SQL string that can be used to add a check constraint to the table
bool manual
manual edits
Definition: SqlUtil.qm.dox.h:8713
const AlignTableOptions
table alignment options
Definition: SqlUtil.qm.dox.h:8471
AbstractPrimaryKey getPrimaryKey()
returns an object of class AbstractPrimaryKey describing the primary key of the table ...
*AbstractIndex findEqual(AbstractIndex ix)
find an index with columns equal to the index passed
bool emptyData()
returns True if the table has no data rows, False if not
bool tableRenamed(string old_name, string new_name, string old_sql_name)
updates table names and internal references for renamed tables
removeSourceConstraint(string tname, list cols)
removes a source constraint
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
abstract string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the constraint in the database
AbstractColumn addColumn(string cname, hash opt, bool nullable=True, *reference lsql)
adds a column to the table; if the table already exists, then it is added in the database also immedi...
int upsertNoCommit(hash row, int upsert_strategy=AbstractTable::UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
*list getCreateForeignConstraintsSql(*hash opt, bool cache=True)
returns a list of SQL strings that could be used to create foreign constraints on the table or NOTHIN...
string getNativeTypeString(string native_type, int precision)
returns the string describing the native type that can be used in SQL (for example to add the column ...
hash getDisableReenableSql(AbstractDatasource ds, string table_name, *hash opts)
returns lists of SQL strings to disable this constraint plus any dependent constraints and another li...
hash cop_lower(any column)
returns a hash for the "lower" operator with the given argument; returns a column value in lower case...
Triggers triggers
trigger descriptions
Definition: SqlUtil.qm.dox.h:8707
*string getRenameTableIfExistsSql(string old_name, string new_name, *hash opts)
returns an SQL string that can be used to rename the given table if it exists and the target does not...
Columns describe()
returns an object of class Columns describing the Table
const DB_PROCEDURES
Feature: procedures.
Definition: SqlUtil.qm.dox.h:1626
const CreationOptions
default generic creation options
Definition: SqlUtil.qm.dox.h:5149
abstract string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
AbstractTable memberGate(string k)
returns the AbstractTable object corresponding to the key given or throws a KEY-ERROR exception ...
const OP_EQ
the SQL equals operator (=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2660
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database; if disabling constraints ...
*AbstractSequence getSequence(string name)
returns an AbstractSequence argument for the given sequence name or NOTHING if the sequence cannot be...
list getDropColumnSql(string cname, *hash opt)
returns the SQL that can be used to drop a column from the table
AbstractPrimaryKey getPrimaryKey()
returns an object of class AbstractPrimaryKey describing the primary key of the table ...
bool dropViewIfExists(string name, *hash opt)
drops the given view if it exists; returns True if the view was dropped, False if not ...
bool exists(...)
AbstractForeignConstraint take(string k)
removes the given key from the contained hash and returns the value
abstract private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
abstract string getElementName()
must return the name of the contained element
*string comment
comment on the column
Definition: SqlUtil.qm.dox.h:3747
Qore::AbstractIterator dropIterator()
returns an iterator for a list of cached table names in the order that can be used to drop the tables...
Qore::AbstractIterator getSourceConstraintIterator()
returns an iterator through all known source foreign constraints on the current table ...
list getAlignFunctionSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a function in the database to the function d...
AbstractIndex dropIndex(string iname, *reference sql)
drops the index from the table; if the table is known to be in the database already, then it is also dropped from the database immediately; otherwise it is only removed internally
string getName()
returns the name of the table
code getUpsertClosure(hash example_row, int upsert_strategy=AbstractTable::UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
bool val()
Returns False if the contained list is empty, True if not.
string getSelectSql(*hash sh, *reference args)
returns the SQL string to be executed corresponding to the argument hash with an output parameter for...
string src
the source code
Definition: SqlUtil.qm.dox.h:4323
bool unique
True if the index is a unique index, False if not
Definition: SqlUtil.qm.dox.h:3899
string getDropIndexSql(string iname, *hash opt)
gets the SQL that can be used to drop an index from the table
list getModifySql(AbstractTable t, AbstractColumn c, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
hash cop_over(any column, string arg)
returns a hash for the "over" clause
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
const AC_Insert
used when data is inserted in a table
Definition: SqlUtil.qm.dox.h:5082
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
add(string k, Table val)
adds the given value to the hash with the given key name
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
constructor(AbstractDatasource ds, *hash opts)
creates the Database object
string getNativeTypeString()
returns the string describing the native type that can be used in SQL (for example to add the colunn ...
Qore::AbstractIterator iterator()
Returns a HashIterator object for the contained hash.
private any tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
Qore::ListIterator tableIterator()
returns an iterator listing the string table names in the database
string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt)
returns an SQL string that can be used to add a foreign constraint to the table
list getCreateSql(*hash opt)
returns a list of SQL strings that could be used to create the table and all known properties of the ...
string getSqlName()
returns the name of the table to be used in SQL (with a possible qualifiers for schema, etc)
abstract list getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table ...
const COP_YEAR_MONTH
to return a date value with year to month information
Definition: SqlUtil.qm.dox.h:1766
string src
the source of the object
Definition: SqlUtil.qm.dox.h:4358
private bool equalImpl(AbstractConstraint c)
returns True if the argument is equal to the current object, False if not
string getElementName()
must return the name of the contained element
private hash getForeignConstraintOptions()
return the foreign constraint options for this driver
const COP_MAX
to return the maximum value
Definition: SqlUtil.qm.dox.h:1721
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql)
drops a foreign constraint from the table; if the table is known to be in the database already...
insert(hash row, *reference sql)
inserts a row into the table; the transaction is committed if successful, if an error occurs...
const COP_AS
to rename a column on output
Definition: SqlUtil.qm.dox.h:1681
string getDriverName()
returns the database driver name
hash cop_divide(any column1, any column2)
returns a hash for the "/" operator with the given arguments
hash op_ge(any arg)
returns a hash for the ">=" operator with the given argument for use in where clauses when comparing ...
abstract list getRenameSql(string table_name, string new_name)
returns a list of SQL strings that can be used to rename the constraint in the database ...
hash cop_seq(string seq)
returns a hash for the "seq" operator with the given argument giving the sequence name whose value sh...
Columns columns
column description object
Definition: SqlUtil.qm.dox.h:8697
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql)
inserts rows into a table based on a select statement from another table (which must be using the sam...
private constructor(AbstractDatasource nds, *hash nopts)
creates the object; private constructor
*AbstractFunction getFunction(string name)
returns an AbstractFunction argument for the given function name or NOTHING if the function cannot be...
const DB_VIEWS
Feature: views.
Definition: SqlUtil.qm.dox.h:1634
hash op_not(hash arg)
returns a hash for the "not" operator; for use in where clauses
Qore::ListIterator procedureIterator()
returns an iterator listing the string procedure names in the database
AbstractForeignConstraint addForeignConstraint(string cname, softlist cols, string table, *softlist tcols, *hash opt, *reference sql)
adds an foreign constraint to the table; if the table is already known to be in the database...
const OP_LE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2640
private hash getCacheOptions()
override in subclasses to return driver-specific options
hash join_inner(string ta, Table table, *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...
const BLOB
specifies a large variable-length binary column (ie BLOB or BYTEA, etc)
Definition: SqlUtil.qm.dox.h:1651
string name
the name of the index
Definition: SqlUtil.qm.dox.h:3896
int insertFromIterator(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
string type(any arg)
hash cop_value(any arg)
returns a hash for the "value" operator with the given argument
AbstractConstraint dropConstraint(string cname, *reference sql)
drops a constraint from the table; this can be any constraint on the table, a primary key...
*string getCreatePrimaryKeySql(*hash opt, bool cache=True)
returns an SQL string that could be used to create the primary key on the table
Columns columns
columns in the target table
Definition: SqlUtil.qm.dox.h:4231
drop(*hash opt)
drops the table from the database; releases the transaction lock after dropping the table ...
const OP_CLE
the SQL less than or equals (<=) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2670
hash join_left(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for left outer joins with the given arguments
AbstractColumn addColumn(string cname, hash opt, bool nullable=True, *reference lsql)
adds a column to the table; if the table is already known to be in the database, then it is added in ...
AbstractColumn modifyColumn(string cname, hash opt, bool nullable=True, *reference lsql)
modifies an existing column in the table; if the table already exists, then the changes are effected ...
const DB_TABLES
Feature: tables.
Definition: SqlUtil.qm.dox.h:1630
list getAlignProcedureSql(AbstractFunction f, *hash opt)
returns a list of SQL strings that can be used to update a stored procedure in the database to the st...
string getElementName()
must return the name of the contained element
*hash select(*hash sh, *reference sql)
returns a hash of lists representing the columns and rows in the table that match the argument hahs ...
const CLOB
specifies a large variable-length character column (ie CLOB or TEXT, etc)
Definition: SqlUtil.qm.dox.h:1654
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
bool supportsTypes()
returns True if the database supports named types
const OP_NOT
the SQL "not" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2705
AbstractColumn renameColumn(string old_name, string new_name, reference sql)
renames an existing column; if the table already exists, then the changes are effected in the databas...
string getRenameSql(string new_name, *hash opt)
returns an SQL string that could be used to rename the table in the database
clear()
purges the contained data
Columns columns
an object of class Columns representing the columns in the index
Definition: SqlUtil.qm.dox.h:3902
*list getCreateConstraintsSql(*hash opt)
returns a list of SQL strings that could be used to create non-foreign constraints on the table or NO...
AbstractForeignConstraint memberGate(string k)
returns the AbstractForeignConstraint object corresponding to the key given or throws a KEY-ERROR exc...
const SqlDataCallbackOptions
generic SQL data operation callbacks
Definition: SqlUtil.qm.dox.h:8538
base class for function or objects with code
Definition: SqlUtil.qm.dox.h:4347
const DB_TYPES
Feature: named types.
Definition: SqlUtil.qm.dox.h:1632
addSourceConstraint(string tname, AbstractForeignConstraint fk)
adds a foreign constraint source to the unique constraint
string getRenameColumnSql(string old_name, string new_name, *hash opt)
gets an SQL string that can be used to rename an existing column in the table
AbstractTable makeTable(string name, hash desc, *hash opts)
creates a database-specific AbstractTable object corresponding to the arguments
bool empty()
returns True if the container is empty, False if not
copy(AbstractTable old)
copies the object
private hash getInsertOptions()
returns the insert options for this driver
Qore::ListIterator viewIterator()
returns an iterator listing the string view names in the database
setDatasource(AbstractDatasource nds)
changes the datasource for the table; if the inDb flag is True, then it is set to False by calling th...
AbstractFunction makeFunction(string name, string src, *hash opt)
creates a database-specific AbstractFunction object corresponding to the arguments ...
const UpsertResultMap
hash mapping upsert results to a description
Definition: SqlUtil.qm.dox.h:8663
findMatchingIndex(*Indexes indexes)
find an index that matches the constraint and marks both objects as related
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
string name
the name of the column
Definition: SqlUtil.qm.dox.h:3729
bool empty()
returns True if the container is empty, False if not
bool supportsSequences()
returns True if the database supports sequences
private hash getAlignSchemaOptions()
override in subclasses to return driver-specific options
string string(softstring str)
private hash getConstraintOptions()
returns the constraint options for this driver
AbstractDatasource ds
the connection to the database server
Definition: SqlUtil.qm.dox.h:4969
string getName()
returns the constraint name
insert(hash row, *reference sql)
inserts a row into the table; the transaction is committed if successful, if an error occurs...
*list getCreateMiscSql(*hash opt)
returns a list of SQL strings that could be used to create other table attributes (such as comments...
abstract private list getModifySqlImpl(AbstractTable t, AbstractColumn c, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition; if the col...
string getName()
returns the index name
base class for functions
Definition: SqlUtil.qm.dox.h:4388
private hash getTableDescriptionHashOptions()
returns the table description hash options for this driver
string getCreateSqlString(*hash opt)
returns an SQL string that could be used to create the table and all known properties of the table ...
const COP_MULTIPLY
the SQL "multiply" operator
Definition: SqlUtil.qm.dox.h:1756
AbstractUniqueConstraint addUniqueConstraint(string cname, softlist cols, *hash opt, *reference sql)
adds a unique constraint to the table; if the table is known to be in the database already...
list listSequences()
returns a list of string sequence names in the database
Constraints constraints
constraint descriptions
Definition: SqlUtil.qm.dox.h:8705
const COP_PREPEND
to prepend a string to a column on output
Definition: SqlUtil.qm.dox.h:1686
list getDropSchemaSql(hash schema_hash, *hash opt)
accepts a hash argument describing a database schema and returns a list of SQL strings that can be us...
hash cop_count(string column="")
returns a hash for the "count" operator; returns row counts
string getDropConstraintSql(string cname, *hash opt)
gets the SQL that can be used to drop a constraint from the table; this can be any constraint on the ...
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
list listFunctions()
returns a list of string function names in the database
bool partialMatchKeys(hash h1)
returns True if the hash argument has at least the same keys (in any order, can have more keys)...
AbstractSequence makeSequence(string name, number start=1, number increment=1, *softnumber end, *hash opts)
creates a database-specific AbstractSequence object corresponding to the arguments ...
const AC_Recreate
used when an object is recreated (usually dropped and recreated in place)
Definition: SqlUtil.qm.dox.h:5079
*string getIndex()
returns the name of the associated index, if any
abstract clearIndex()
clears any index base for the constraint
base class for views
Definition: SqlUtil.qm.dox.h:4312
bool dropTableIfExists(string name, *hash opt)
drops the given table if it exists; returns True if the table was dropped, False if not ...
bool hasKey(string k)
Returns True if the key exists in the contained hash (may or may not be assigned a value)...
bool equal(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
abstract list getRenameSql(string new_name)
returns a string that can be used to rename the function in the database
*hash opts
option hash
Definition: SqlUtil.qm.dox.h:4975
string getCreateSqlString(*hash opt)
returns an SQL string that could be used to create the table and all known properties of the table ...
AbstractTable getTable()
returns the AbstractTable object contained by this object
bool native_case
native case option
Definition: SqlUtil.qm.dox.h:5212
*list getCreateConstraintsSql(*hash opt, bool cache=True)
returns a list of SQL strings that could be used to create non-foreign constraints on the table or NO...
list getAddColumnSql(string cname, hash copt, bool nullable=True, *hash opt)
returns a list of SQL strings that can be use to add a column to the table
bool checkExistence()
returns True if the table exists in the database, False if not
AbstractFunction makeProcedure(string name, string src, *hash opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
renameKey(string old_name, string new_name)
renames the given key; maintains the key order
*hash selectRow(*hash sh, *reference sql)
returns a hash representing the row in the table that matches the argument hash; if more than one row...
list getModifyColumnSql(string cname, hash copt, bool nullable=True, *hash opt)
gets a list of SQL strings that can be used to modify an existing column in the table ...
private hash getTableCreationOptions()
returns the table creation options for this driver
const InsertOptions
default insert option keys
Definition: SqlUtil.qm.dox.h:8559
Qore::SQL::AbstractDatasource getDatasource()
gets the underlying AbstractDatasource
AbstractTrigger take(string k)
removes the given key from the contained hash and returns the value
abstract private bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
any tryExecRaw(string sql)
executes some SQL so that if an error occurs the current transaction state is not lost ...
*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...
insertNoCommit(hash row, *reference sql)
inserts a row into the table without any transaction management; a transaction will be in progress af...
const TriggerOptions
default trigger options
Definition: SqlUtil.qm.dox.h:8416
*list findAll(*hash cond)
finds all rows in the table with the given column values; a list of hashes is returned representing t...
hash cop_prepend(any column, string arg)
returns a hash for the "prepend" operator with the given argument
AbstractForeignConstraint dropForeignConstraint(string cname, *reference sql)
drops the foreign constraint from the table; if the table is known to be in the database already...
string type
the type of object
Definition: SqlUtil.qm.dox.h:4355
setupTable(hash desc, *hash opt)
creates the object from a table description hash
const Int
AbstractIndex renameIndex(string old_name, string new_name, reference sql)
renames an existing index; if the table is already known to be in the database, then the changes are ...
abstract private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch)
processes a string for use in SQL select statements when there is an "order by" and "offset" argument...
*list findAll(*hash cond)
finds all rows in the table with the given column values; a list of hashes is returned representing t...
const COP_YEAR
to return a date value with year information only
Definition: SqlUtil.qm.dox.h:1761
constructor(softlist nl)
creates the object with the list argument passed
bool hasColumn(string cname)
returns True if the constraint references the named column
Triggers getTriggers()
returns an object of class Triggers describing the triggers on the table
const SequenceDescriptionOptions
default generic sequence description keys
Definition: SqlUtil.qm.dox.h:5202
AbstractCheckConstraint addCheckConstraint(string cname, string src, *hash opt, *reference sql)
adds a check constraint to the table; if the table is already known to be in the database, then it is added in the database also immediately; otherwise it is only added internally and can be created when create() is called for example
abstract list getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the trigger in the database
*list getCreateIndexesSql(*hash opt)
returns a list of SQL strings that could be used to create indexes on the table or NOTHING if there a...
softint rowCount()
returns the number of rows in the table
rollback()
rolls back the current transaction on the underlying Qore::SQL::AbstractDatasource ...
string getElementName()
returns "table" since this object stores AbstractTable objects
list getDropPrimaryKeySql(*hash opt)
gets a list of SQL strings that can be used to drop the primary key from the table ...
abstract private hash getTypeMapImpl()
returns the type name -> type description hash
string getDropSql()
returns a string that can be used to drop the view from the database
dropNoCommit(*hash opt)
drops the table from the database without any transaction management
string getElementName()
returns "foreign constraint" for the type of object encapsulated
int size
the size of the column
Definition: SqlUtil.qm.dox.h:3738
AbstractColumn renameColumn(string old_name, string new_name, reference sql)
renames an existing column; if the table is already known to be in the database, then the changes are...
string getSqlFromList(list l)
returns an SQL string corresponding to the list of commands in the argument
bool dropTableIfExists(string name, *hash opt)
drops the given table if it exists; returns True if the table was dropped, False if not ...
list listProcedures()
returns a list of string procedure names in the database
list getModifyColumnSql(string cname, hash copt, bool nullable=True, *hash opt)
gets a list of SQL strings that can be used to modify an existing column in the table ...
string getSqlValue(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
int size()
Returns the number of keys in the contained hash.
private any tryExecRawImpl(string sql)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
Qore::AbstractIterator keyIterator()
Returns a HashKeyIterator object for the contained hash.
private hash getWhereOperatorMap()
returns the "where" operator map for this object
*hash upsertFromIteratorNoCommit(Qore::AbstractIterator i, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
this method upserts or merges data from the given iterator argument (whose getValue() method must ret...
any tryExecArgs(string sql, *softlist args)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
abstract string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
string native_type
the native type name of the column
Definition: SqlUtil.qm.dox.h:3732
const COP_VALUE
to append a constant value to use as an output column value
Definition: SqlUtil.qm.dox.h:1696
truncateNoCommit()
truncates all the table data without any transaction management
column container class that throws an exception if an unknown column is accessed
Definition: SqlUtil.qm.dox.h:3677
the base class for triggers
Definition: SqlUtil.qm.dox.h:4449
hash join_right(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for right outer joins with the given arguments
hash op_eq(any arg)
returns a hash for the "=" operator with the given argument for use in where clauses when comparing c...
private hash getAlignTableOptions()
returns the align table options for this driver
int insertFromSelect(list cols, AbstractTable source, *hash sh, *reference sql)
inserts rows into a table based on a select statement from another table (which must be using the sam...
const OP_LT
the SQL less than (<) operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2635
string dsdesc
datasource description
Definition: SqlUtil.qm.dox.h:4971
*hash findSingle(*hash cond)
finds a single row in the table that match the row condition passed; multiple rows may match...
setDatasource(AbstractDatasource nds)
changes the datasource for the table; if the inDb flag is True, then it is set to False by calling th...
bool empty()
returns True if the table has no definitions, False if not
const AlignSchemaOptions
default generic schema description / alignment options
Definition: SqlUtil.qm.dox.h:5159
*hash findConstraintOn(string table, softlist cols)
returns either a hash of AbstractColumn information or NOTHING if no foreign constraint can be found ...
add(string k, AbstractForeignConstraint val)
adds the given value to the hash with the given key name
function container class that throws an exception if an unknown function is accessed ...
Definition: SqlUtil.qm.dox.h:4411
Indexes getIndexes()
returns an object of class Indexes describing the indexes on the table
const UR_Unchanged
row was unchanged (only possible with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8654
AbstractPrimaryKey dropPrimaryKey(*reference lsql)
drops the primary key from the table; if the table is known to be in the database already...
rename(string new_name, *reference sql, *Tables table_cache)
renames the table; if the table already exists in the database, then the changes are effected in the ...
const UR_Updated
row was updated because it was different (only possible with UpsertSelectFirst)
Definition: SqlUtil.qm.dox.h:8651
int getNextSequenceValue(string name)
returns the next value in the given sequence
AbstractDatabase db
the embedded AbstractDatabase object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:4520
the base class for column information
Definition: SqlUtil.qm.dox.h:3724
truncate()
truncates all the table data; releases the transaction lock after executing
bool hasColumn(string cname)
returns True if the constraint references the named column
const UpsertInsertOnly
Upsert option: insert if the row does not exist, otherwise ignore.
Definition: SqlUtil.qm.dox.h:8615
setName(string new_name)
sets the new name of the object
hash join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
returns a hash for standard inner joins with the given arguments
AbstractPrimaryKey dropPrimaryKey(*reference lsql)
drops the primary key from the table; if the table is known to be in the database already...
add(string k, AbstractTrigger val)
adds the given value to the hash with the given key name
const OP_CGE
the SQL greater than or equals operator (>=) for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2680
const AC_Truncate
used when a table is truncated
Definition: SqlUtil.qm.dox.h:5073
hash op_cle(string arg)
returns a hash for the "<=" operator with the given argument for use in where clauses when comparing ...
string getName()
returns the name of the table
represents a database table; this class embeds an AbstractTable object that is created automatically ...
Definition: SqlUtil.qm.dox.h:5833
const IndexOptions
default index options
Definition: SqlUtil.qm.dox.h:8390
private hash getColumnOptions()
returns the column options for this driver
list values()
Returns a list of values of the contained hash.
AbstractConstraint dropConstraint(string cname, *reference sql)
drops a constraint from the table; this can be any constraint on the table, a primary key...
*hash find(any id)
finds a row in the table with the given primary key value; if no row matches the primary key value pa...
bool equal(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
rename(string new_name, *reference sql, *Tables table_cache)
renames the table; if the table is already known to be in the database in the database, then the changes are effected in the database also immediately; otherwise it is only updated internally
AbstractTable take(string k)
removes the given key from the contained hash and returns the value
hash make_cop(string cop, any column, any arg)
returns a hash with cop, column, and arg keys
const COP_MIN
to return the minimum value
Definition: SqlUtil.qm.dox.h:1716
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:8601
bool dropFunctionIfExists(string name, *hash opt)
drops the given function if it exists; returns True if the function was dropped, False if not ...
const COP_YEAR_DAY
to return a date value with year to day information
Definition: SqlUtil.qm.dox.h:1771
dropNoCommit(*hash opt)
drops the table from the database without any transaction management
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy=AbstractTable::UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
const Closure
setupTable(hash desc, *hash opt)
creates the object from a table description hash
add(string k, AbstractIndex val)
adds the given value to the hash with the given key name
AbstractFunction makeProcedure(string name, string src, *hash opt)
creates a database-specific AbstractFunction object for a stored procedure corresponding to the argum...
const UpsertInsertFirst
Upsert option: insert first, if the insert fails, then update.
Definition: SqlUtil.qm.dox.h:8584
private hash getCallbackOptions()
override in subclasses to return driver-specific options
*hash selectRow(*hash sh, *reference sql)
returns a hash representing the row in the table that matches the argument hash; if more than one row...
AbstractIndex addIndex(string iname, bool unique, softlist cols, *hash opt, *reference sql)
adds an index to the table; if the table already exists, then it is added in the database also immedi...
string name
the name of the sequence
Definition: SqlUtil.qm.dox.h:4320
*hash findSingle(*hash cond)
finds a single row in the table that match the row condition passed; multiple rows may match...
constructor(string n, string n_src)
creates the object and sets its name and the trigger source
list features()
See DBFeaturesConstants.
*number max
the ending number
Definition: SqlUtil.qm.dox.h:4292
abstract private bool checkExistenceImpl()
returns True if the table exists in the DB, False if not
hash cop_upper(any column)
returns a hash for the "upper" operator with the given argument; returns a column value in upper case...
code getUpsertClosure(hash example_row, int upsert_strategy=UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
bool val()
Returns False if the contained hash has no keys, True if it does.
string getAddForeignConstraintSql(string cname, softlist cols, string table, *softlist tcols, *hash fkopt, *hash opt)
returns an SQL string that can be used to add a foreign constraint to the table
*list selectRows(*hash sh, *reference sql)
returns a list of hashes representing the rows in the table that match the argument hash ...
list getList()
returns the list contained by this object
Qore::SQL::SQLStatement getRowIterator(*hash sh, *reference sql)
returns an SQLStatement object that will iterate the results of a select statement matching the argum...
const ColumnDescOptions
Column description options.
Definition: SqlUtil.qm.dox.h:8514
number increment
the increment
Definition: SqlUtil.qm.dox.h:4289
*string getDropConstraintIfExistsSql(string cname, *hash opt, *reference cref)
gets the SQL that can be used to drop a constraint from the table if it exists, otherwise returns NOT...
AbstractColumn memberGate(string k)
returns the AbstractColumn object corresponding to the key given or throws a KEY-ERROR exception ...
bool matchKeys(hash h1)
returns True if the hash argument has the same keys (in any order), False if not
list listViews()
returns a list of string view names in the database
*string getDropProcedureSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given procedure if it exists or NOTHING if the named procedure do...
bool inDb()
returns True if the table has been read from or created in the database, False if not ...
const OP_LIKE
the SQL "like" operator for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2630
rollback()
rolls back the current transaction on the underlying Qore::SQL::AbstractDatasource ...
const CallbackOptions
generic callback options
Definition: SqlUtil.qm.dox.h:5043
const TableDescriptionHashOptions
Table description options.
Definition: SqlUtil.qm.dox.h:8491
const SZ_NONE
the data type does not take a size parameter
Definition: SqlUtil.qm.dox.h:1662
AbstractIndex memberGate(string k)
returns the AbstractIndex object corresponding to the key given or throws a KEY-ERROR exception ...
int size()
Returns the number of elements in the contained list.
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
list getDropList()
returns a list of cached table names in the order that can be used to drop the tables, taking into account foreign constraint dependencies
AbstractTrigger addTrigger(string tname, string src, *hash opt, *reference lsql)
adds a trigger to the table; if the table is already known to be in the database, then it is added in...
const ActionDescMap
maps from action descriptions to action codes
Definition: SqlUtil.qm.dox.h:5111
AbstractTable t
the embedded AbstractTable object that actually provides the functionality for this class ...
Definition: SqlUtil.qm.dox.h:5838
code getUpsertClosureWithValidation(hash example_row, int upsert_strategy=UpsertAuto)
returns a closure that can be executed given a hash argument representing a single row that will be u...
abstract private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
const OP_CLT
the SQL less than (<) operator for use in Where Clauses when comparing two columns ...
Definition: SqlUtil.qm.dox.h:2665
const COP_MINUS
the SQL "minus" operator
Definition: SqlUtil.qm.dox.h:1741
*AbstractFunction getProcedure(string name)
returns an AbstractFunction argument for the given stored procedure name or NOTHING if the stored pro...
clear()
purges the current table definition
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
clearIndex()
clears any index base for the constraint
string table
the name of the target table
Definition: SqlUtil.qm.dox.h:4228
hash hash(object obj)
commit()
commits the current transaction on the underlying Qore::SQL::AbstractDatasource
abstract private int getNextSequenceValueImpl(string name)
returns the next value in the given sequence
commit()
commits the current transaction on the underlying Qore::SQL::AbstractDatasource
private hash getColumnDescOptions()
returns the column description options for this driver
*AbstractUniqueConstraint findUniqueConstraint(string name)
returns the given AbstractUniqueConstraint object if defined for the table (also includes the primary...
const TableCreationOptions
table creation options
Definition: SqlUtil.qm.dox.h:8459
hash cop_year_day(any column)
returns a hash for the "year_day" operator with the given argument
const AC_Delete
used when data is deleted in a table
Definition: SqlUtil.qm.dox.h:5088
Qore::ListIterator functionIterator()
returns an iterator listing the string function names in the database
list listTables()
returns a list of string table names in the database
*list getCreateMiscSql(*hash opt, bool cache=True)
returns a list of SQL strings that could be used to create other table attributes (such as comments...
abstract string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
const JOP_RIGHT
for right outer joins
Definition: SqlUtil.qm.dox.h:2314
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
AbstractTrigger dropTrigger(string tname, *reference sql)
drops the given trigger from the table; if the table is known to be in the database already...
hash make_uop(string uop, any arg, *hash nest)
returns a hash with uop, arg, and nest keys
const SZ_OPT
the data type takes an optional size parameter
Definition: SqlUtil.qm.dox.h:1668
const AC_Update
used when data is updated in a table
Definition: SqlUtil.qm.dox.h:5085
int insertFromIteratorNoCommit(Qore::AbstractIterator i, *hash opt)
this method inserts data from the given iterator argument (whose getValue() method must return a hash...
private hash getInsertOperatorMap()
returns the insert operator map for this object
*string getDropConstraintIfExistsSql(string tname, string cname, *hash opts)
returns an SQL string that can be used to drop an existing constraint on a table, if the table is not...
AbstractSequence makeSequence(string name, number start=1, number increment=1, *softnumber end, *hash opts)
creates a database-specific AbstractSequence object corresponding to the arguments ...
hash cop_year(any column)
returns a hash for the "year" operator with the given argument
number start
the starting number
Definition: SqlUtil.qm.dox.h:4286
const IOP_SEQ
for using the value of a sequence
Definition: SqlUtil.qm.dox.h:3091
const AC_NotFound
used when dropping object but the object is not present
Definition: SqlUtil.qm.dox.h:5091
list getDropTriggerSql(string tname, *hash opt)
returns SQL that can be used to drop the given trigger from the table
populate(AbstractDatasource ds, hash tables, *hash opt)
populates the object from a hash description
the base abstract class for the database implementation
Definition: SqlUtil.qm.dox.h:5017
int insertFromSelectNoCommit(list cols, AbstractTable source, *hash sh, *reference sql)
inserts rows into a table based on a select statement from another table (which must be using the sam...
private hash getTableOptions()
returns the table options for this driver
*list getDropTableSqlIfExists(string name, *hash opt)
returns the SQL require to drop the given table if it exists or NOTHING if the named table does not e...
int upsert(hash row, int upsert_strategy=AbstractTable::UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
Qore::AbstractIterator getUniqueConstraintIterator()
returns an iterator for all unique constraints on the table (including the primary key if any) ...
any take(int i)
removes the given element from the contained list and returns the value
hash cop_multiply(any column1, any column2)
returns a hash for the "*" operator with the given arguments
*hash select(*hash sh, *reference sql)
returns a hash of lists representing the columns and rows in the table that match the argument hahs ...
const AC_Add
used when an element is added to an existing object
Definition: SqlUtil.qm.dox.h:5076
truncateNoCommit()
truncates all the table data without any transaction management
string getCreateTableSql(*hash opt)
returns an SQL string that could be used to create the basic table structure without indexes and cons...
string getDropSql(string table_name)
returns a string that can be used to drop the index from the database
string getDropConstraintSql(string cname, *hash opt)
gets the SQL that can be used to drop a constraint from the table; this can be any constraint on the ...
*AbstractForeignConstraint findEqual(AbstractForeignConstraint fk)
find an index with columns equal to the index passed
ForeignConstraints getForeignConstraints(*hash opt)
returns a ForeignConstraints object describing the foreign constraints that the table has on other ta...
represents a primary key
Definition: SqlUtil.qm.dox.h:4165
const JOP_INNER
for standard inner joins
Definition: SqlUtil.qm.dox.h:2304
const COP_LOWER
to return column value in lower case
Definition: SqlUtil.qm.dox.h:1706
*AbstractTable getTable(string name)
returns an AbstractTable argument for the given table name or NOTHING if the table cannot be found ...
private hash getSequenceDescriptionOptions()
override in subclasses to return driver-specific options
private any tryExecArgsImpl(string sql, *softlist args)
tries to execute a command so that if an error occurs the current transaction status is not lost ...
list getDropColumnSql(string cname, *hash opt)
returns the SQL that can be used to drop a column from the table
const COP_DIVIDE
the SQL "divide" operator
Definition: SqlUtil.qm.dox.h:1751
string join(string str,...)
const DB_FUNCTIONS
Features constants.
Definition: SqlUtil.qm.dox.h:1620
const NUMERIC
specifies a numeric column (equivalent to Qore::Type::Number)
Definition: SqlUtil.qm.dox.h:1645
abstract list getCreateSql(*hash opt)
returns a list of SQL strings that can be used to create the function in the database ...
abstract bool setIndexBase(string ix)
returns True if the object supports an index property and is set, False if not
hash op_ceq(string arg)
returns a hash for the "=" operator with the given argument for use in where clauses when comparing t...
*list selectRows(*hash sh, *reference sql)
returns a list of hashes representing the rows in the table that match the argument hash ...
string getDropSql(string table_name)
returns a string that can be used to drop the column from the table
const UpsertStrategyDescriptionMap
hash mapping upsert strategy descriptions to upsert strategy codes
Definition: SqlUtil.qm.dox.h:8631
*string lastKey()
Returns the last key name in the contained hash or NOTHING if the contained hash has no keys...
int delNoCommit(*hash cond, *reference sql)
deletes rows in the table matching the condition and returns the count of rows deleted; no transactio...
private bool equalImpl(AbstractConstraint con)
returns True if the argument is equal to the current object, False if not
AbstractConstraint take(string k)
removes the given key from the contained hash and returns the value
*string firstKey()
Returns the first key name in the contained hash or NOTHING if the contained hash has no keys...
*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...
bool supportsSequences()
returns True if the database supports sequences
*hash upsertFromIteratorNoCommit(Qore::AbstractIterator i, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
this method upserts or merges data from the given iterator argument (whose getValue() method must ret...
any tryExec(string sql)
executes some SQL with optional arguments so that if an error occurs the current transaction state is...
hash cop_year_hour(any column)
returns a hash for the "year_hour" operator with the given argument
bool hasKeyValue(string k)
Returns True if the key exists in the contained hash and is assigned a value, False if not...
const ConstraintOptions
default constraint options
Definition: SqlUtil.qm.dox.h:8398
*AbstractTable getIfExists(AbstractDatasource ds, string name)
gets a table from the database or from the cache if already cached; if the table does not exist...
const DefaultOpMap
a hash of valid operators for use in Where Clauses
Definition: SqlUtil.qm.dox.h:2708
represents a unique column constraint
Definition: SqlUtil.qm.dox.h:4094
rename(string n)
renames the constraint
private hash getUpsertOptions()
returns the upsert options for this driver
AbstractTable makeTable(string name, hash desc, *hash opts)
creates a database-specific AbstractTable object corresponding to the arguments
const AdditionalColumnDescOptions
additional column description keys valid when describing columns in a table description hash ...
Definition: SqlUtil.qm.dox.h:8527
hash cop_max(any column)
returns a hash for the "max" operator; returns maximum column values
abstract base class for constraints
Definition: SqlUtil.qm.dox.h:4005
string getSqlValue(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument ...
hash uop_seq(string seq)
returns a hash for the "seq" operator with the given argument giving the sequence name whose value sh...
AbstractForeignConstraint removeForeignConstraint(string cname)
removes the named foreign constraint from the table; no SQL is executed in any case, only the named foreign constraint is removed from the table definition
int upsertNoCommit(hash row, int upsert_strategy=UpsertAuto)
update or insert the data in the table according to the hash argument; the table must have a unique k...
constraint container class that throws an exception if an unknown constraint is accessed ...
Definition: SqlUtil.qm.dox.h:3963
const COP_APPEND
to append a string to a column on output
Definition: SqlUtil.qm.dox.h:1691