Qore OracleSqlUtil Module Reference  1.2.5
 All Classes Namespaces Functions Variables Groups Pages
OracleSqlUtil.qm.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // @file OracleSqlUtil.qm Qore user module for working with Oracle SQL data
3 
4 /* OracleSqlUtil.qm Copyright 2013 - 2018 Qore Technologies, s.r.o.
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.13 or better
26 
27 // requires the SqlUtil module
28 
29 // requires the Util module
30 
31 // for bindOracleCollection
32 
33 // don't use "$" signs for variables and class members, assume local variable scope
34 
35 // require type definitions everywhere
36 
37 // enable all warnings
38 
39 
40 /* Version History: see docs below
41 */
42  a.*, rownum rnum from (select * from schema.table where type = %v order by type) a where rownum <= %v) where rnum > %v", ("user", 300, 200));
72  @endcode
73  note that the following simpler SQL is generated for Oracle 12c+ servers:
74  @code{.py}
75 $ds.vselectRows("select * from schema.table where type = %v order by type offset %v rows fetch next %v rows only", ("user", 200, 100));
76  @endcode
77 
78  @subsection ora_in_operator IN Operator on Oracle
79 
80  In order to avoid dynamic SQL and better manage the server's shared pool (in particular, the number of parsed statements), the %OracleSqlUtil
81  module uses bind by value with the SQL \c IN operator.
82 
83  For example, the following query:
84  @code{.py}
85 my *hash $q = $table.select(("where": ("col1": op_in(1, 2, 3, 4))));
86  @endcode
87 
88  Results in the equivalent of the following SQL:
89  @code{.py}
90 my *hash $q = $ds.select("select * from schema.table where col1 in (select column_value from table(%v))", bindOracleCollection("SYS.ODCIVARCHAR2LIST", (1,2,3,4)));
91  @endcode
92 
93  @htmlonly <style><!-- td.qore { background-color: #5b9409; color: white; } --></style> @endhtmlonly
94  <table>
95  <tr>
96  <td class="qore"><b>Qore Type</b></td>
97  <td class="qore"><b>Oracle Collection</b></td>
98  </tr>
99  <tr>
100  <td>Date</td>
101  <td>\c SYS.ODCIDATELIST</td>
102  </tr>
103  <tr>
104  <td>Float</td>
105  <td>\c SYS.ODCINUMBERLIST</td>
106  </tr>
107  <tr>
108  <td>Integer</td>
109  <td>\c SYS.ODCINUMBERLIST</td>
110  </tr>
111  <tr>
112  <td>Number</td>
113  <td>\c SYS.ODCINUMBERLIST</td>
114  </tr>
115  <tr>
116  <td>String</td>
117  <td>\c SYS.ODCIVARCHAR2LIST</td>
118  </tr>
119  </table>
120 
121  There universal collections are limited to 32767 elements. And \c SYS.ODCIVARCHAR2LIST element size is \c VARCHAR2(4000).
122 
123  @subsection ora_partitioning_select Partition Support in Selects
124 
125  It's possible to select from a particular partition of a table with %OracleSqlUtil;
126  @ref OracleSqlUtil::OracleTable::OracleSelectOptions "OracleSelectOptions" defines the \c "partition" key which can be added to a
127  @ref select_option_hash "select option hash" to specify the partition to select from as in the following example:
128  @code{.py}
129 my *list $rows = $table.selectRows(("created": op_gt(2012-05-01), "partition": "p1"));
130  @endcode
131  Which generates an SQL command like the following:
132  @code{.py}
133 my *list $rows = $ds.vselectRows("select * from schema.table partition(p1) where created > %v", (2012-05-01));
134  @endcode
135 
136  @subsection ora_partitioning_join Partition Support in Joins
137 
138  It's possible to perform a join on a particular partition of a table with %OracleSqlUtil; the join option \c "partition" is
139  supported to specify the partition to join on as in the following example:
140  @code{.py}
141 my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid"), NOTHING, ("partition": "p2"))));
142  @endcode
143  Which generates an SQL command like the following:
144  @code{.py}
145 my *list $rows = $ds.vselectRows("select * from schema.table inner join schema.table2 partition(p2) t2 on (schema.table.id = t2.altid)");
146  @endcode
147 
148  @section ora_schema_management Schema Management on Oracle
149 
150  Note that when getting an object description from an Oracle database, if the object cannot be found in the connection schema, then
151  if a synonym of the same type exists and the target object is accessible, then the target object is read automatically and the owning
152  schema name is also set to the actual owner of the object.
153 
154  @subsection ora_type_mapping Type Mapping
155 
156  Column types are mapped from %Qore types as follows:
157 
158  <b>Oracle Column Type Mappings</b>
159  <table>
160  <tr>
161  <td class="qore"><b>Generic Type Name</b></td>
162  <td class="qore"><b>Oracle Type Used</b></td>
163  </tr>
164  <tr>
165  <td>\c float</td>
166  <td>\c number</td>
167  </tr>
168  <tr>
169  <td>\c integer</td>
170  <td>\c number</td>
171  </tr>
172  <tr>
173  <td>\c number</td>
174  <td>\c number</td>
175  </tr>
176  <tr>
177  <td>\c string</td>
178  <td>\c varchar2</td>
179  </tr>
180  <tr>
181  <td>\c date</td>
182  <td>\c timestamp(6)</td>
183  </tr>
184  <tr>
185  <td>\c binary</td>
186  <td>\c blob</td>
187  </tr>
188  <tr>
189  <td>@ref SqlUtil::BLOB</td>
190  <td>\c blob</td>
191  </tr>
192  <tr>
193  <td>@ref SqlUtil::CHAR</td>
194  <td>\c char</td>
195  </tr>
196  <tr>
197  <td>@ref SqlUtil::CLOB</td>
198  <td>\c clob</td>
199  </tr>
200  <tr>
201  <td>@ref SqlUtil::NUMERIC</td>
202  <td>\c number</td>
203  </tr>
204  <tr>
205  <td>@ref SqlUtil::VARCHAR</td>
206  <td>\c varchar2</td>
207  </tr>
208  </table>
209 
210  To use other types, use the \c "native_type" @ref SqlUtil::AbstractTable::ColumnDescOptions "column description option" with the
211  native Oracle type name instead (under the \c "driver" and \c "oracle" keys for schemas supporting multiple databases).
212 
213  @subsection ora_other_objects Additional Object Types Supported
214 
215  The following additional schema objects can be managed with %OracleSqlUtil:
216  - @ref ora_materialized_views "materialized views"
217  - @ref ora_packages "packages"
218  - @ref ora_types "types"
219 
220  @subsection ora_materialized_views Materialized Views
221 
222  The @ref schema_desc_hash takes an optional key, \c "materialized_views" that allows materialized views in Oracle schemas to be managed along with other objects.
223 
224  The \c "materialized_views" should be assigned to a hash, each key name is the name of the materialized view, and the values are hashes with the
225  following keys:
226  - \c "logging": (@ref bool_type "bool") if the materialized view should be logged
227  - \c "use_index": (@ref bool_type "bool") if the materialized view should be indexed
228  - \c "src": (@ref bool_type "bool") the source of the materialized view
229 
230  The \c "materialized_views" key can go in the top level of the @ref schema_desc_hash for Oracle-only schemas, or, for schemas targeting multiple database types, under the \c "driver" and \c "oracle" keys as in the following example:
231 
232  @code{.py}
233 hash schema = (
234  "driver": (
235  "oracle": (
236  "materialized_views": (
237  "example_mv": (
238  "logging": False,
239  "use_index": False,
240  "src": "select type, count(1) total_count from table group by type",
241  ),
242  ),
243  ),
244  ),
245 );
246  @endcode
247 
248  @subsection ora_packages Packages
249 
250  The @ref schema_desc_hash takes an optional key, \c "packages" that allows packages in Oracle schemas to be managed along with other objects.
251 
252  The \c "packages" should be assigned to a hash, each key name is the name of the package, and the values are hashes with the
253  following key:
254  - \c "src": (@ref bool_type "bool") the source of the package
255 
256  The \c "packages" key can go in the top level of the @ref schema_desc_hash for Oracle-only schemas, or, for schemas targeting multiple database types, under the \c "driver" and \c "oracle" keys as in the following example:
257 
258  @code{.py}
259 hash schema = (
260  "driver": (
261  "oracle": (
262  "packages": (
263  "example_pkg": (
264  "src": "types as
265 type cursorType is ref cursor;
266 MYSTATCOMPLETE constant order_status.orderstatus%type := 'C';
267 MYSTATERROR constant order_status.orderstatus%type := 'E';
268 ",
269  ),
270  ),
271  ),
272  ),
273 );
274  @endcode
275 
276  @subsection ora_types Types
277 
278  The @ref schema_desc_hash takes an optional key, \c "types" that allows types in Oracle schemas to be managed along with other objects.
279 
280  The \c "types" should be assigned to a hash, each key name is the name of the type, and the values are strings giving the type definition.
281 
282  The \c "types" key can go in the top level of the @ref schema_desc_hash for Oracle-only schemas, or, for schemas targeting multiple database types, under the \c "driver" and \c "oracle" keys as in the following example:
283 
284  @code{.py}
285 hash schema = (
286  "driver": (
287  "oracle": (
288  "types": (
289  "num_array": "table of number",
290  "str_array": "table of varchar2(240)",
291  ),
292  ),
293  ),
294 );
295  @endcode
296 
297  @see OracleSqlUtil::OracleDatabase::OracleSchemaDescriptionOptions for a list of Oracle-specific schema description hash keys.
298 
299  @section ora_relnotes Release Notes
300 
301  @subsection v125 OracleSqlUtil v1.2.5
302  - worked around an Oracle bug in materialized view creation where when the schema user is missing the <tt>CREATE MATERIALIZED VIEW</tt> grant the table backing the view is created but the materialized view itself is not created causing future creation actions to fail (<a href="https://github.com/qorelanguage/qore/issues/2643">issue 2643</a>)
303 
304  @subsection v124 OracleSqlUtil v1.2.4
305  - implemented support for custom column operators (<a href="https://github.com/qorelanguage/qore/issues/2314">issue 2314</a>)
306  - implemented support for chained synonyms (<a href="https://github.com/qorelanguage/qore/issues/2408">issue 2408</a>)
307  - allow to use DBA_* views instead of ALL_* if possible (<a href="https://github.com/qorelanguage/qore/issues/2418">issue 2418</a>)
308 
309  @subsection v123 OracleSqlUtil v1.2.3
310  - fixed a bug in \c character_semantics for standalone column (<a href="https://github.com/qorelanguage/qore/issues/1688">issue 1688</a>)
311  - implemented @ref cop_trunc_date() operator (<a href="https://github.com/qorelanguage/qore/issues/2032">issue 2032</a>)
312 
313  @subsection v122 OracleSqlUtil v1.2.2
314  - fixed a bug in the \a force option (i.e. cascade) for dropping types (<a href="https://github.com/qorelanguage/qore/issues/1683">issue 1683</a>)
315 
316  @subsection v121 OracleSqlUtil v1.2.1
317  - implemented the \a force option (i.e. cascade) for dropping code objects (<a href="https://github.com/qorelanguage/qore/issues/1314">issue 1314</a>)
318  - worked around ORA-22165 from op_in() caused by Oracle's limit on number of collection elements (<a href="https://github.com/qorelanguage/qore/issues/1660">issue 1660</a>)
319 
320  @subsection v12 OracleSqlUtil v1.2
321  - implemented support for the \c "returning" clause as an insert option
322  - implemented support for views for DML in the @ref OracleSqlUtil::OracleTable class
323  - implemented @ref OracleSqlUtil::OracleTable::getBaseType()
324  - implemented support for Oracle pseudocolumns in queries
325  - implemented support for @ref SqlUtil::cop_cast() operator
326  - fixed bugs in @ref SqlUtil::cop_seq() and @ref SqlUtil::cop_seq_currval() (<a href="https://github.com/qorelanguage/qore/issues/624">issue 624</a>)
327  - return lists from Oracle's data dictionary ordered
328  - implemented @ref OracleSqlUtil::OracleTable::bindEmptyStringsAsNull()
329  - implemented high-performance "upsert" (merge) support also supporting bulk DML
330  - implemented @ref SqlUtil::cop_substr() and @ref SqlUtil::uop_substr() operators (<a href="https://github.com/qorelanguage/qore/issues/801">issue 801</a>)
331  - implemented @ref SqlUtil::op_substr() where operator (<a href="https://github.com/qorelanguage/qore/issues/883">issue 883</a>)
332 
333  @subsection v11 OracleSqlUtil v1.1
334  - fixed selects with "limit" but no "offset"
335  - convert date/time values to timestamps with microseconds resolution instead of dates with second resolution when dynamically inserting values as strings in SQL (binding by value not affected)
336  - fixed schema information classes when the "string-numbers" driver option is enabled
337 
338  @subsection v10 OracleSqlUtil v1.0
339  - initial release
340 */
341 
343 namespace OracleSqlUtil {
345  OracleTable get_table(AbstractDatasource nds, string nname, *hash opts);
346 
347 
349  OracleDatabase get_database(AbstractDatasource nds, *hash opts);
350 
351 
354 
355 public:
356  public :
358  bool char_used;
361 
362 public:
363 
364  constructor(string n, string nt, *string qt, softint sz, bool nul, *string dv, *string cm, bool is_char = False, bool cu = False, softint bs) ;
365 
366 
368  string getNativeTypeString();
369 
370 
372 
379  list getAddColumnSql(AbstractTable t);
380 
381 
383 
393  list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
394 
395 
397 
407  string getRenameSql(AbstractTable t, string new_name);
408 
409 
411  bool equalImpl(AbstractColumn c);
412 
413  };
414 
417 
418 public:
419  constructor(string n, string nt, *string qt, softint sz, bool nul, *string dv, *string cm, softint bs, softint n_scale = 0) ;
420 
421 
422  string getNativeTypeString();
423 
424  };
425 
428 
429 public:
430  public :
432  string native_type;
433 
435  *string tablespace;
436 
437 public:
438 
440  constructor(string n, bool u, hash c, string nt, *string t) ;
441 
442 
444  string getCreateSql(string table_name, *hash opt);
445 
446 
448  bool equalImpl(AbstractIndex ix);
449 
450 
452  string getRenameSql(string table_name, string new_name);
453 
454  };
455 
458 
459 public:
460  public :
462  bool enabled;
463 
464 public:
465 
466  constructor(string n, Columns c, ForeignConstraintTarget t, bool e) ;
467 
468 
469  string getCreateSql(string table_name, *hash opt);
470 
471 
472  softlist getRenameSql(string table_name, string new_name);
473 
474 
476  string getDisableSql(string table_name);
477 
478 
480  string getEnableSql(string table_name, *hash opt);
481 
482  };
483 
486 
487 public:
488  public :
490  bool enabled;
491 
492 public:
493 
494  constructor(string n, string n_src, bool e = True) ;
495 
496 
497  string getCreateSql(string table_name, *hash opt);
498 
499 
500  softlist getRenameSql(string table_name, string new_name);
501 
502 
504  string getDisableSql(string table_name);
505 
506 
508  string getEnableSql(string table_name, *hash opt);
509 
510  };
511 
514 
515 public:
516  private :
518  bool enabled;
519 
521  *string tablespace;
522 
523 public:
524 
525  constructor(string n, hash n_cols, bool e = True, *string ts) ;
526 
527 
529 
544  OracleColumn memberGate(string k);
545 
546 
547  bool setIndexBase(string ix);
548 
549 
551  clearIndex();
552 
553 
554  string getCreateSql(string table_name, *hash opts);
555 
556 
557  softlist getRenameSql(string table_name, string new_name);
558 
559 
561  string getDisableSql(string table_name);
562 
563 
565  string getEnableSql(string table_name, *hash opt);
566 
567 
569  bool isEnabled();
570 
571 
573  *string getTablespace();
574 
575  };
576 
579 
580 public:
581  private :
583  *string tablespace;
584 
585 public:
586 
587  constructor();
588 
589 
590  constructor(string n, *hash c, *string ts) ;
591 
592 
594 
609  OracleColumn memberGate(string k);
610 
611 
612  bool setIndexBase(string ix);
613 
614 
616  clearIndex();
617 
618 
619  string getCreateSql(string table_name, *hash opts);
620 
621 
622  softlist getRenameSql(string table_name, string new_name);
623 
624 
626 
628  string getDropSql(string table_name);
629 
630 
632  string getDisableSql(string table_name);
633 
634 
636  string getEnableSql(string table_name, *hash opt);
637 
638  };
639 
642 
643 public:
645  constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end) ;
646 
647 
649  string getCreateSql(*hash opt);
650 
651 
653 
657  softlist getRenameSql(string new_name, *hash opt);
658 
659  };
660 
663 
664 public:
665  public :
667  *string type_text;
669  *string oid_text;
673  *string view_type;
675  *string superview_name;
678 
679 public:
680 
682  constructor(string n_name, string n_src, *string n_schema, *string n_type_text,
683  *string n_oid_text, *string n_view_type_owner,
684  *string n_view_type, *string n_superview_name,
685  bool n_updatable, bool n_container_data)
686  ;
687 
688 
690  string getCreateSql(*hash opt);
691 
692 
694 
698  softlist getRenameSql(string new_name, *hash opt);
699 
700  };
701 
704 
705 public:
706  public :
708  bool enabled;
709 
710 public:
711 
712  constructor(string n, string n_src, bool en = True) ;
713 
714 
715  softlist getCreateSql(string table_name, *hash opt);
716 
717 
719  bool equalImpl(AbstractFunctionBase t);
720 
721 
723  softlist getRenameSql(string table_name, string new_name);
724 
725 
727  softlist getDropSql(string table_name);
728 
729  };
730 
733 
734 public:
736 
740  constructor(string n, string n_type, string n_src) ;
741 
742 
744 
746  softlist getCreateSql(*hash opt);
747 
748 
750  bool equalImpl(AbstractFunctionBase t);
751 
752 
754 
758  softlist getRenameSql(string new_name, *hash opt);
759 
760  };
761 
764 
765 public:
767 
771  constructor(string n, string n_type, string n_src) ;
772 
773 
775 
780  softlist getRenameSql(string new_name, *hash opt);
781 
782  };
783 
786 
787 public:
788  constructor(string n_name, string n_src) ;
789 
790 
792 
794  string getDropSql(*hash opt);
795 
796  };
797 
800 
801 public:
803 
806  constructor(string n, string n_src) ;
807 
808  };
809 
812 
813 public:
815 
818  constructor(string n, string n_src) ;
819 
820  };
821 
824 
825 public:
826  public :
828  *string body_src;
829 
830 public:
831 
833 
837  constructor(string n, string n_src, *string n_body_src) ;
838 
839 
841  list getCreateSql(*hash opt);
842 
843 
845  bool equalImpl(AbstractFunctionBase t);
846 
847  };
848 
851 
852 public:
853  public :
855  bool logging;
857  bool use_index;
859  *string tablespace;
860 
861 public:
862 
864 
870  constructor(string n, string n_src, bool n_logging = True, bool n_use_index = True, *string n_tablespace) ;
871 
872 
874  softlist getCreateSql(*hash opt);
875 
876 
877  bool equalImpl(AbstractFunctionBase t);
878 
879  };
880 
883 
884 public:
885  public :
887  const OracleCreationOptions = AbstractDatabase::CreationOptions + (
888  "compute_statistics": Type::Boolean,
889  );
890 
892  const OracleAlignSchemaOptions = AbstractDatabase::AlignSchemaOptions
893  + OracleCreationOptions
894  + OracleTable::OracleAlignTableOptions
895  ;
896 
898 
906  const OracleSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + (
907  "types": Type::Hash,
908  "type_map": Type::Hash,
909 
910  "packages": Type::Hash,
911  "package_map": Type::Hash,
912 
913  "materialized_views": Type::Hash,
914  "materialized_view_map": Type::Hash,
915 
916  //"synonyms": Type::Hash,
917  //"synonym_map": Type::Hash,
918  );
919 
921  const OraclePackageDescriptionOptions = (
922  "src": Type::String,
923  "body": Type::String,
924  );
925 
927  const OracleMaterializedViewDescriptionOptions = (
928  "logging": Type::Boolean,
929  "use_index": Type::Boolean,
930  "tablespace": Type::String,
931  "src": Type::String,
932  );
933 
935  const OracleReservedWords = (
936  "access": True,
937  "else": True,
938  "modify": True,
939  "start": True,
940  "add": True,
941  "exclusive": True,
942  "noaudit": True,
943  "select": True,
944  "all": True,
945  "exists": True,
946  "nocompress": True,
947  "session": True,
948  "alter": True,
949  "file": True,
950  "not": True,
951  "set": True,
952  "and": True,
953  "float": True,
954  "notfound": True,
955  "share": True,
956  "any": True,
957  "for": True,
958  "nowait": True,
959  "size": True,
960  "arraylen": True,
961  "from": True,
962  "null": True,
963  "smallint": True,
964  "as": True,
965  "grant": True,
966  "number": True,
967  "sqlbuf": True,
968  "asc": True,
969  "group": True,
970  "of": True,
971  "successful": True,
972  "audit": True,
973  "having": True,
974  "offline": True,
975  "synonym": True,
976  "between": True,
977  "identified": True,
978  "on": True,
979  "sysdate": True,
980  "by": True,
981  "immediate": True,
982  "online": True,
983  "table": True,
984  "char": True,
985  "in": True,
986  "option": True,
987  "then": True,
988  "check": True,
989  "increment": True,
990  "or": True,
991  "to": True,
992  "cluster": True,
993  "index": True,
994  "order": True,
995  "trigger": True,
996  "column": True,
997  "initial": True,
998  "pctfree": True,
999  "uid": True,
1000  "comment": True,
1001  "insert": True,
1002  "prior": True,
1003  "union": True,
1004  "compress": True,
1005  "integer": True,
1006  "privileges": True,
1007  "unique": True,
1008  "connect": True,
1009  "intersect": True,
1010  "public": True,
1011  "update": True,
1012  "create": True,
1013  "into": True,
1014  "raw": True,
1015  "user": True,
1016  "current": True,
1017  "is": True,
1018  "rename": True,
1019  "validate": True,
1020  "date": True,
1021  "level": True,
1022  "resource": True,
1023  "values": True,
1024  "decimal": True,
1025  "like": True,
1026  "revoke": True,
1027  "varchar": True,
1028  "default": True,
1029  "lock": True,
1030  "row": True,
1031  "varchar2": True,
1032  "delete": True,
1033  "long": True,
1034  "view": True,
1035  "desc": True,
1036  "maxextents": True,
1037  "rowlabel": True,
1038  "whenever": True,
1039  "distinct": True,
1040  "minus": True,
1041  "rownum": True,
1042  "where": True,
1043  "drop": True,
1044  "mode": True,
1045  "rows": True,
1046  "with": True,
1047  );
1048 
1050  const OracleRebuildIndexOptions = (
1051  "parallel" : Type::Boolean,
1052  "logging" : Type::Boolean,
1053  "statictics" : Type::Boolean,
1054  "tablespace" : Type::String,
1055  "cond_rebuild" : Type::Boolean,
1056  "cond_maxheight" : Type::Int,
1057  "cond_maxleafpct" : Type::Int,
1058  );
1059 
1061  const OracleComputeStatisticsOptions = ComputeStatisticsOptions + (
1062  "estimate_percent" : Type::Int,
1063  "block_sample" : Type::Boolean,
1064  "method_opt" : Type::String,
1065  "degree" : Type::Int,
1066  "granularity" : Type::String,
1067  "cascade" : Type::Boolean,
1068  "stattab" : Type::String,
1069  "statid" : Type::String,
1070  "options" : Type::String,
1071  "statown" : Type::String,
1072  );
1073 
1074 public:
1075 
1077  constructor(AbstractDatasource nds, *hash opts) ;
1078 
1079 
1080 
1081 private:
1082  list featuresImpl();
1083 public:
1084 
1085 
1086 
1087 private:
1088  OracleSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
1089 public:
1090 
1091 
1092 
1093 private:
1094  getSchemaName(reference<string> name, reference<string> schema);
1095 public:
1096 
1097 
1098 
1099 private:
1100  *AbstractSequence getSequenceImpl(string name);
1101 public:
1102 
1103 
1104 
1105 private:
1106  *AbstractView getViewImpl(string name);
1107 public:
1108 
1109 
1110 
1111 private:
1112  OracleFunction makeFunctionImpl(string name, string src, *hash opts);
1113 public:
1114 
1115 
1116 
1117 private:
1118  OracleProcedure makeProcedureImpl(string name, string src, *hash opts);
1119 public:
1120 
1121 
1122 
1123 private:
1124  OraclePackage makePackage(string name, string src, string body, *hash opts);
1125 public:
1126 
1127 
1128 
1129 private:
1130  OraclePackage makePackageFromDescription(string name, hash ph, *hash opts);
1131 public:
1132 
1133 
1134 
1135 private:
1136  OracleType makeType(string name, string src, *hash opts);
1137 public:
1138 
1139 
1140 
1141 private:
1142  OracleMaterializedView makeMaterializedView(string name, string src, bool logging = True, bool use_index = True, *string tablespace, *hash opts);
1143 public:
1144 
1145 
1146 
1147 private:
1148  OracleMaterializedView makeMaterializedViewFromDescription(string name, hash mvh, *hash opts);
1149 public:
1150 
1151 
1152 
1153 private:
1154  list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
1155 public:
1156 
1157 
1158 
1159 private:
1160  list getAlignSqlImpl(hash schema_hash, *hash opt);
1161 public:
1162 
1163 
1164 
1165 private:
1166  *OracleFunction getFunctionImpl(string name);
1167 public:
1168 
1169 
1170 
1171 private:
1172  *OracleProcedure getProcedureImpl(string name);
1173 public:
1174 
1175 
1177  *OraclePackage getPackage(string name);
1178 
1179 
1181  *OracleType getType(string name);
1182 
1183 
1185  *OracleMaterializedView getMaterializedView(string name);
1186 
1187 
1188 
1189 private:
1190  *string getSource(string type, string name);
1191 public:
1192 
1193 
1194 
1195 private:
1196  checkSource(string type, string name, reference<string> src);
1197 public:
1198 
1199 
1201  list listSynonyms();
1202 
1203 
1205  ListIterator synonymIterator();
1206 
1207 
1209  list listTypes();
1210 
1211 
1213  ListIterator typeIterator();
1214 
1215 
1217  list listPackages();
1218 
1219 
1221  ListIterator packageIterator();
1222 
1223 
1225  list listMaterializedViews();
1226 
1227 
1229  ListIterator materializedViewIterator();
1230 
1231 
1232 
1233 private:
1234  list listTablesImpl();
1235 public:
1236 
1237 
1238 
1239 private:
1240  list listFunctionsImpl();
1241 public:
1242 
1243 
1244 
1245 private:
1246  list listProceduresImpl();
1247 public:
1248 
1249 
1250 
1251 private:
1252  list listSequencesImpl();
1253 public:
1254 
1255 
1256 
1257 private:
1258  list listViewsImpl();
1259 public:
1260 
1261 
1262 
1263 private:
1264  list getListIntern(string type);
1265 public:
1266 
1267 
1268 
1269 private:
1270  list getListIntern(list l);
1271 public:
1272 
1273 
1274 
1275 private:
1276  string getCreateSqlImpl(list l);
1277 public:
1278 
1279 
1280  static string getCreateSql(list l);
1281 
1283 
1284 private:
1285  hash getCreationOptions();
1286 public:
1287 
1288 
1290 
1291 private:
1292  hash getAlignSchemaOptions();
1293 public:
1294 
1295 
1297 
1298 private:
1299  hash getSchemaDescriptionOptions();
1300 public:
1301 
1302 
1304 
1305 private:
1306  hash getRebuildIndexOptions();
1307 public:
1308 
1309 
1311 
1312 private:
1313  hash getComputeStatisticsOptions();
1314 public:
1315 
1316 
1318 
1319 private:
1320  softint getNextSequenceValueImpl(string name);
1321 public:
1322 
1323 
1325 
1326 private:
1327  softint getCurrentSequenceValueImpl(string name);
1328 public:
1329 
1330 
1332 
1333 private:
1334  bool supportsSequencesImpl();
1335 public:
1336 
1337 
1339 
1340 private:
1341  bool supportsTypesImpl();
1342 public:
1343 
1344 
1346 
1347 private:
1348  bool supportsPackagesImpl();
1349 public:
1350 
1351 
1353 
1365  bool rebuildIndexAnalyze(AbstractIndex index, int maxh, int maxleaf);
1366 
1367 
1369 
1381  bool rebuildIndexAnalyze(string name, int maxh, int maxleaf);
1382 
1383 
1385 
1386 private:
1387  bool rebuildIndexImpl(string name, *hash options);
1388 public:
1389 
1390 
1392 
1393 private:
1394  computeStatisticsImpl(*hash options);
1395 public:
1396 
1397 
1399 
1400 private:
1401  computeStatisticsSchemaImpl(*hash options);
1402 public:
1403 
1404 
1406 
1407 private:
1408  computeStatisticsTablesImpl(*hash options);
1409 public:
1410 
1411 
1413 
1414 private:
1415  reclaimSpaceImpl(*hash options);
1416 public:
1417 
1418 
1419 
1420 private:
1421  oracleErrorCallback(int ac, string type, string name, *string table, *string new_name, *string info, string sql, hash<ExceptionInfo> ex);
1422 public:
1423 
1424  };
1425 
1427 
1430 
1431 public:
1432  public :
1434  const OraTypeMap = (
1435  "number": ("qore": Type::Number, "size": SZ_NUM, "size_range": (1, 38), "scale_range": (-84, 127)),
1436  "varchar2": ("qore": Type::String, "size": SZ_MAND, "size_range": (1, 4000), "is_char": True),
1437  "char": ("qore": Type::String, "size": SZ_MAND, "size_range": (1, 4000), "is_char": True),
1438  "date": ("qore": Type::Date,),
1439  "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1440  "timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1441  "timestamp with local time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1442  "interval year to month": ("qore": Type::Date,),
1443  "interval day to second": ("qore": Type::Date,),
1444  "timestamp(0)": ("qore": Type::Date,),
1445  "timestamp(1)": ("qore": Type::Date,),
1446  "timestamp(2)": ("qore": Type::Date,),
1447  "timestamp(3)": ("qore": Type::Date,),
1448  "timestamp(4)": ("qore": Type::Date,),
1449  "timestamp(5)": ("qore": Type::Date,),
1450  "timestamp(6)": ("qore": Type::Date,),
1451  "timestamp(7)": ("qore": Type::Date,),
1452  "timestamp(8)": ("qore": Type::Date,),
1453  "timestamp(9)": ("qore": Type::Date,),
1454  "timestamp(0) with time zone": ("qore": Type::Date,),
1455  "timestamp(1) with time zone": ("qore": Type::Date,),
1456  "timestamp(2) with time zone": ("qore": Type::Date,),
1457  "timestamp(3) with time zone": ("qore": Type::Date,),
1458  "timestamp(4) with time zone": ("qore": Type::Date,),
1459  "timestamp(5) with time zone": ("qore": Type::Date,),
1460  "timestamp(6) with time zone": ("qore": Type::Date,),
1461  "timestamp(7) with time zone": ("qore": Type::Date,),
1462  "timestamp(8) with time zone": ("qore": Type::Date,),
1463  "timestamp(9) with time zone": ("qore": Type::Date,),
1464  "timestamp(0) with local time zone": ("qore": Type::Date,),
1465  "timestamp(1) with local time zone": ("qore": Type::Date,),
1466  "timestamp(2) with local time zone": ("qore": Type::Date,),
1467  "timestamp(3) with local time zone": ("qore": Type::Date,),
1468  "timestamp(4) with local time zone": ("qore": Type::Date,),
1469  "timestamp(5) with local time zone": ("qore": Type::Date,),
1470  "timestamp(6) with local time zone": ("qore": Type::Date,),
1471  "timestamp(7) with local time zone": ("qore": Type::Date,),
1472  "timestamp(8) with local time zone": ("qore": Type::Date,),
1473  "timestamp(9) with local time zone": ("qore": Type::Date,),
1474  "interval year(0) to month": ("qore": Type::Date,),
1475  "interval year(1) to month": ("qore": Type::Date,),
1476  "interval year(2) to month": ("qore": Type::Date,),
1477  "interval year(3) to month": ("qore": Type::Date,),
1478  "interval year(4) to month": ("qore": Type::Date,),
1479  "interval year(5) to month": ("qore": Type::Date,),
1480  "interval year(6) to month": ("qore": Type::Date,),
1481  "interval year(7) to month": ("qore": Type::Date,),
1482  "interval year(8) to month": ("qore": Type::Date,),
1483  "interval year(9) to month": ("qore": Type::Date,),
1484  "interval day(0) to second(0)": ("qore": Type::Date,),
1485  "interval day(0) to second(1)": ("qore": Type::Date,),
1486  "interval day(0) to second(2)": ("qore": Type::Date,),
1487  "interval day(0) to second(3)": ("qore": Type::Date,),
1488  "interval day(0) to second(4)": ("qore": Type::Date,),
1489  "interval day(0) to second(5)": ("qore": Type::Date,),
1490  "interval day(0) to second(6)": ("qore": Type::Date,),
1491  "interval day(0) to second(7)": ("qore": Type::Date,),
1492  "interval day(0) to second(8)": ("qore": Type::Date,),
1493  "interval day(0) to second(9)": ("qore": Type::Date,),
1494  "interval day(1) to second(0)": ("qore": Type::Date,),
1495  "interval day(1) to second(1)": ("qore": Type::Date,),
1496  "interval day(1) to second(2)": ("qore": Type::Date,),
1497  "interval day(1) to second(3)": ("qore": Type::Date,),
1498  "interval day(1) to second(4)": ("qore": Type::Date,),
1499  "interval day(1) to second(5)": ("qore": Type::Date,),
1500  "interval day(1) to second(6)": ("qore": Type::Date,),
1501  "interval day(1) to second(7)": ("qore": Type::Date,),
1502  "interval day(1) to second(8)": ("qore": Type::Date,),
1503  "interval day(1) to second(9)": ("qore": Type::Date,),
1504  "interval day(2) to second(0)": ("qore": Type::Date,),
1505  "interval day(2) to second(1)": ("qore": Type::Date,),
1506  "interval day(2) to second(2)": ("qore": Type::Date,),
1507  "interval day(2) to second(3)": ("qore": Type::Date,),
1508  "interval day(2) to second(4)": ("qore": Type::Date,),
1509  "interval day(2) to second(5)": ("qore": Type::Date,),
1510  "interval day(2) to second(6)": ("qore": Type::Date,),
1511  "interval day(2) to second(7)": ("qore": Type::Date,),
1512  "interval day(2) to second(8)": ("qore": Type::Date,),
1513  "interval day(2) to second(9)": ("qore": Type::Date,),
1514  "clob": ("qore": Type::String,),
1515  "blob": ("qore": Type::Binary,),
1516  "long": ("qore": Type::Binary,),
1517  "raw": ("qore": Type::Binary, "size": SZ_MAND, "size_range": (1, 2000)),
1518  "bfile": ("qore": Type::Binary,),
1519  "binary_float": ("qore": Type::Float,),
1520  "binary_double": ("qore": Type::Float,),
1521  "rowid": ("qore": Type::String,),
1522  "urowid": ("qore": Type::String, "size": SZ_OPT, "size_range": (1, 4000)),
1523  );
1524 
1526  const QoreTypeMap = (
1527  "integer": "number",
1528  "float": "number",
1529  "number": "number",
1530  "string": "varchar2",
1531  "date": "timestamp(6)",
1532  "binary": "blob",
1533  SqlUtil::CHAR: "char",
1534  SqlUtil::CLOB: "clob",
1535  SqlUtil::BLOB: "blob",
1536  );
1537 
1538  const OraColumnOpts = (
1539  "character_semantics": Type::Boolean,
1540  );
1541 
1543 
1546  const OraColumnOptions = AbstractTable::ColumnOptions + OraColumnOpts;
1547 
1549 
1552  const OraColumnDescOptions = AbstractTable::ColumnDescOptions + OraColumnOpts;
1553 
1555 
1558  const OracleIndexOptions = AbstractTable::IndexOptions + (
1559  "compute_statistics": Type::Boolean,
1560  );
1561 
1563 
1566  const OracleConstraintOptions = OracleIndexOptions + (
1567  "index": Type::String,
1568  );
1569 
1571  const OracleTableCreationOptions = AbstractTable::TableCreationOptions
1572  + OracleConstraintOptions
1573  + OraColumnOptions
1574  ;
1575 
1576  const OracleAlignTableOptions = AbstractTable::AlignTableOptions + OracleTableCreationOptions;
1577 
1579 
1583  const OracleSelectOptions = AbstractTable::SelectOptions + (
1584  "partition": Type::String,
1585  );
1586 
1588  const OracleOpMap = DefaultOpMap + (
1589  OP_IN: (
1590  "code": string (object t, string cn, softlist arg, reference<list> args, *hash jch, bool join = False, *hash ch, *hash psch) {
1591  // Qorus bug #989 SqlUtil: oracle op_in can fail in large amount of input elements
1592  // There is no support for CLOBs in WHERE clause in Oracle at all.
1593  // Binding large strings (over 4000 chars is performed by a CLOB in Qore driver.
1594  // Result of op_in operator can be "ORA-00932: inconsistent datatypes" if is
1595  // the list longer or if it contains large items with:
1596  // return cn + " in (select regexp_substr(%v,'[^,]+', 1, level) from dual connect by regexp_substr(%v, '[^,]+', 1, level) is not null)";
1597 
1598  // determine list members type. Let's assume the 1st non NULL/NOTHING
1599  // element gives the type code for all elements.
1600  ListIterator it(arg);
1601  int ltype;
1602  while (it.next());
1603 
1604 
1605  // Split long array to chunks of no more than 32767 elements due to Oracle limitation
1606  // "ORA-22165: OCI-22165: given index [32767] must be in the range of [0] to [32766]"
1607  int count;
1608  while (arg.size());
1609 
1610 
1611  if (count)
1612  return cn + " in (" + (map "select column_value from table(%v)", xrange(1,count)).join(" union all ") + ")";
1613  else
1614  return "1 != 1";
1615  throw "MISSING-ORACLE-DRIVER", "op_in requires oracle driver";
1616  },
1617  ),
1618  OP_SUBSTR: (
1619  "code": string (object t, string cn, auto arg, reference<list> args, *hash jch, bool join = False, *hash ch, *hash psch) {
1620  args += arg[0]; // start
1621  if (!exists arg[1]);
1622 
1623  args += arg[1]; // count
1624  args += arg[2]; // text
1625  return sprintf("substr(%s,%v,%v) = %v", cn);
1626  },
1627  ),
1628  );
1629 
1631  const OracleCopMap = (
1632  COP_CAST: (
1633  "code": string (string cve, list args) {
1634  string name = QoreTypeMap{args[0]} ?? args[0];
1635  hash desc = OraTypeMap{name};
1636  string sql = sprintf ("cast (%s as %s", cve, name);
1637  switch (name);
1638 
1639  sql += ")";
1640  return sql;
1641  },
1642  ),
1643  COP_SUBSTR: (
1644  "code": string (string cve, list args) {
1645  if (!exists args[1])
1646  return sprintf("substr(%s,%d)", cve, args[0]);
1647  return sprintf("substr(%s,%d,%d)", cve, args[0], args[1]);
1648  },
1649  ),
1650  COP_YEAR: (
1651  "code": string (string arg1, auto arg) {
1652  return sprintf("to_char(%s, 'YYYY')", arg1);
1653  }
1654  ),
1655  COP_YEAR_MONTH: (
1656  "code": string (string arg1, auto arg) {
1657  return sprintf("to_char(%s, 'YYYY-MM')", arg1);
1658  }
1659  ),
1660  COP_YEAR_DAY: (
1661  "code": string (string arg1, auto arg) {
1662  return sprintf("to_char(%s, 'YYYY-MM-DD')", arg1);
1663  }
1664  ),
1665  COP_YEAR_HOUR: (
1666  "code": string (string arg1, auto arg) {
1667  return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", arg1);
1668  }
1669  ),
1670  COP_SEQ: (
1671  "nocolumn": True,
1672  "withalias": True,
1673  "code": string (*string cve, hash arg, reference<hash> psch) {
1674  string sql = sprintf("%s.nextval", arg.seq);
1675  if (arg.as);
1676 
1677  return sql;
1678  }
1679  ),
1680  COP_SEQ_CURRVAL: (
1681  "nocolumn": True,
1682  "withalias": True,
1683  "code": string (*string cve, hash arg, reference<hash> psch) {
1684  string sql = sprintf("%s.currval", arg.seq);
1685  if (arg.as);
1686 
1687  return sql;
1688  }
1689  ),
1690  COP_TRUNC_DATE: (
1691  "code": string sub(string arg1, auto arg) {
1692  if (!OracleTruncDate.hasKey(arg));
1693 
1694  // seconds are not part of TRUNC() in oracle
1695  if (exists OracleTruncDate{arg});
1696 
1697  // for timestamps
1698  return sprintf("cast (%s as date)", arg1);
1699  }
1700  )
1701  );
1702 
1704  const OracleTruncDate = (
1705  DT_YEAR : "'YYYY'",
1706  DT_MONTH : "'MM'",
1707  DT_DAY : "'DD'",
1708  DT_HOUR : "'HH24'",
1709  DT_MINUTE : "'MI'",
1710  DT_SECOND : NOTHING,
1711  );
1712 
1714  const OracleIopMap = DefaultIopMap + (
1715  IOP_SEQ: (
1716  "arg": Type::String,
1717  "immediate": True,
1718  "code": string (string cve, string arg) {
1719  return sprintf("%s.nextval", arg);
1720  },
1721  ),
1722  IOP_SEQ_CURRVAL: (
1723  "arg": Type::String,
1724  "immediate": True,
1725  "code": string (string cve, string arg) {
1726  return sprintf("%s.currval", arg);
1727  },
1728  ),
1729  );
1730 
1732  const OracleUopMap = DefaultUopMap + (
1733  COP_SEQ: (
1734  "nocolumn": True,
1735  "code": string (*string cve, string arg) {
1736  return sprintf("%s.nextval", arg);
1737  }
1738  ),
1739  COP_SEQ_CURRVAL: (
1740  "nocolumn": True,
1741  "code": string (*string cve, string arg) {
1742  return sprintf("%s.currval", arg);
1743  }
1744  ),
1745  );
1746 
1748  const OraclePseudoColumnHash = (
1749  "rowid": True,
1750  "rownum": True,
1751  "object_id": True,
1752  "object_value": True,
1753  "ora_rowscn": True,
1754  );
1755 
1756 public:
1757 
1758  private :
1759  // schema name
1760  string schema;
1761 
1762  // tablespace name
1763  *string tablespace;
1764 
1765  // is the table read only?
1766  bool readonly;
1767 
1768  // table comment
1769  *string comment;
1770 
1771  // dblink
1772  *string dblink;
1773 
1774  // Oracle server major version
1775  int ora_major;
1776 
1777  // helper flag to indicate if is the OracleTable real table or a view
1778  bool m_isView = False;
1779 
1780  // oraclesqlutil: allow to use DBA_* views instead of ALL_* if possible #2418
1781  // An internal cache to find the highest priority available
1782  // system dictionary object. Priority: DBA > ALL
1783  hash m_sys_views = (
1784  "dba_col_comments" : "all_col_comments",
1785  "dba_cons_columns" : "all_cons_columns",
1786  "dba_constraints" : "all_constraints",
1787  "dba_db_links" : "all_db_links",
1788  "dba_ind_columns" : "all_ind_columns",
1789  "dba_ind_expressions" : "all_ind_expressions",
1790  "dba_indexes" : "all_indexes",
1791  "dba_objects" : "all_objects",
1792  "dba_sequences" : "all_sequences",
1793  "dba_synonyms" : "all_synonyms",
1794  "dba_tab_columns" : "all_tab_columns",
1795  "dba_tab_comments" : "all_tab_comments",
1796  "dba_tables" : "all_tables",
1797  "dba_triggers" : "all_triggers",
1798  "dba_views" : "all_views",
1799  );
1800 
1801 public:
1802 
1803  constructor(AbstractDatasource nds, string nname, *hash opts) ;
1804 
1805 
1806  // oraclesqlutil: allow to use DBA_* views instead of ALL_* if possible #2418
1807  // get the most appropriate system catalogue/dictinary view available
1808 
1809 private:
1810  string systemView(string name);
1811 public:
1812 
1813 
1814 
1815 private:
1816  bool checkExistenceImpl();
1817 public:
1818 
1819 
1820 
1821 private:
1822  setTableInfoIntern();
1823 public:
1824 
1825 
1827  string getSqlName();
1828 
1829 
1831  bool isView();
1832 
1833 
1834 
1835 private:
1836  hash setSchemaTable();
1837 public:
1838 
1839 
1840 
1841 private:
1842  setDblinkSchema();
1843 public:
1844 
1845 
1846  // Oracle has supprt for unlimitted synonym loops. There
1847  // can be mo relevels of synonyms before the real object
1848  // is listed.
1849 
1850 private:
1851  *hash resolveSynonym(string s_owner, string s_name);
1852 public:
1853 
1854 
1855 
1856 private:
1857  hash setTable();
1858 public:
1859 
1860 
1861 
1862 private:
1863  string getUserSchema();
1864 public:
1865 
1866 
1867 
1868 private:
1869  string getDBString();
1870 public:
1871 
1872 
1874  string getSchemaName();
1875 
1876 
1878  *string getTablespaceName();
1879 
1880 
1882  *string getComment();
1883 
1884 
1885  bool readOnly();
1886 
1887 
1888 
1889 private:
1890  hash getColumnOptions();
1891 public:
1892 
1893 
1894 
1895 private:
1896  hash getColumnDescOptions();
1897 public:
1898 
1899 
1901 
1902 private:
1903  hash getSelectOptions();
1904 public:
1905 
1906 
1907 
1908 private:
1909  getSelectWhereSqlUnlocked(reference<string> sql, reference<list> args, *hash qh, *hash jch, bool join = False, *hash ch, *hash psch);
1910 public:
1911 
1912 
1913 
1914 private:
1915  doSelectOrderByWithOffsetSqlUnlockedImpl(reference<string> sql, reference<list> args, *hash qh, *hash jch, *hash ch, *hash psch, list coll);
1916 public:
1917 
1918 
1920 
1921 private:
1922  doSelectLimitOnlyUnlockedImpl(reference<string> sql, reference<list> args, *hash qh);
1923 public:
1924 
1925 
1926 
1927 private:
1928  Columns describeImpl();
1929 public:
1930 
1931 
1932 
1933 private:
1934  OraclePrimaryKey getPrimaryKeyImpl();
1935 public:
1936 
1937 
1938 
1939 private:
1940  Indexes getIndexesImpl();
1941 public:
1942 
1943 
1944 
1945 private:
1946  ForeignConstraints getForeignConstraintsImpl(*hash opts);
1947 public:
1948 
1949 
1950 
1951 private:
1952  Constraints getConstraintsImpl();
1953 public:
1954 
1955 
1956 
1957 private:
1958  string getSelectSqlName(*hash qh);
1959 public:
1960 
1961 
1962 
1963 private:
1964  Triggers getTriggersImpl();
1965 public:
1966 
1967 
1968  string getCreateTableSqlImpl(*hash opt);
1969 
1970 
1971 
1972 private:
1973  *list getCreateMiscSqlImpl(*hash opt, bool cache);
1974 public:
1975 
1976 
1977 
1978 private:
1979  string getCreateSqlImpl(list l);
1980 public:
1981 
1982 
1983 
1984 private:
1985  string getRenameSqlImpl(string new_name);
1986 public:
1987 
1988 
1989 
1990 private:
1991  AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
1992 public:
1993 
1994 
1995 
1996 private:
1997  AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
1998 public:
1999 
2000 
2001 
2002 private:
2003  AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
2004 public:
2005 
2006 
2007 
2008 private:
2009  AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
2010 public:
2011 
2012 
2013 
2014 private:
2015  AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
2016 public:
2017 
2018 
2019 
2020 private:
2021  AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
2022 public:
2023 
2024 
2025 
2026 private:
2027  AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
2028 public:
2029 
2030 
2031 
2032 private:
2033  bool tryInsertImpl(string sql, hash row);
2034 public:
2035 
2036 
2037 
2038 private:
2039  *list getAlignSqlImpl(AbstractTable t, *hash opt);
2040 public:
2041 
2042 
2043 
2044 private:
2045  hash getQoreTypeMapImpl();
2046 public:
2047 
2048 
2049 
2050 private:
2051  hash getTypeMapImpl();
2052 public:
2053 
2054 
2055 
2056 private:
2057  hash getIndexOptions();
2058 public:
2059 
2060 
2061 
2062 private:
2063  hash getConstraintOptions();
2064 public:
2065 
2066 
2067 
2068 private:
2069  hash getTableCreationOptions();
2070 public:
2071 
2072 
2073 
2074 private:
2075  hash getAlignTableOptions();
2076 public:
2077 
2078 
2080 
2081 private:
2082  hash getWhereOperatorMap();
2083 public:
2084 
2085 
2087 
2088 private:
2089  hash getColumnOperatorMapImpl();
2090 public:
2091 
2092 
2094 
2095 private:
2096  hash getInsertOperatorMap();
2097 public:
2098 
2099 
2101 
2102 private:
2103  hash getRawUpdateOperatorMap();
2104 public:
2105 
2106 
2108 
2109 private:
2110  *hash getPseudoColumnHash();
2111 public:
2112 
2113 
2115 
2116 private:
2117  *string getSqlValueImpl(auto v);
2118 public:
2119 
2120 
2122  string getColumnSqlName(string col);
2123 
2124 
2126  list getColumnSqlNames(softlist cols);
2127 
2128 
2130 
2133  string getBaseType();
2134 
2135 
2137  code getBulkUpsertClosure(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
2138 
2139 
2141  code getUpsertClosure(hash row, int upsert_strategy = UpsertAuto, *hash opt);
2142 
2143 
2145 
2146 private:
2147  code getUpsertInsertOnly(Columns cols, hash row, *hash opt);
2148 public:
2149 
2150 
2152 
2153 private:
2154  code getUpsertUpdateOnly(Columns cols, hash row, *hash opt);
2155 public:
2156 
2157 
2159  bool hasArrayBind();
2160 
2161 
2163 
2165  bool bindEmptyStringsAsNull();
2166 
2167 
2169 
2170 private:
2171  bool asteriskRequiresPrefix();
2172 public:
2173 
2174 
2175 
2176 private:
2177  *hash doReturningImpl(hash opt, reference<string> sql, list args);
2178 public:
2179 
2180 
2181 
2182 private:
2183  bool emptyImpl();
2184 public:
2185 
2186 
2187 
2188 private:
2189  setupTableImpl(hash desc, *hash opt);
2190 public:
2191 
2192 
2194 
2195 private:
2196  bool constraintsLinkedToIndexesImpl();
2197 public:
2198 
2199 
2201 
2202 private:
2203  bool uniqueIndexCreatesConstraintImpl();
2204 public:
2205 
2206 
2208 
2209 private:
2210  bool supportsTablespacesImpl();
2211 public:
2212 
2213 
2215 
2216 private:
2217  copyImpl(AbstractTable old);
2218 public:
2219 
2220  };
2221 };
represents an Oracle unique constraint
Definition: OracleSqlUtil.qm.dox.h:513
const Date
represents an Oracle materialized view
Definition: OracleSqlUtil.qm.dox.h:850
date date(date dt)
const COP_SEQ
const Hash
const UpsertAuto
const String
const DefaultIopMap
string sprintf(string fmt,...)
const OP_IN
hash< ColumnOperatorInfo > cop_cast(auto column, string arg, auto arg1, auto arg2)
const VARCHAR
*string tablespace
the tablespace name of the index (if supported)
Definition: OracleSqlUtil.qm.dox.h:435
bool logging
Flag if is loggign mode used.
Definition: OracleSqlUtil.qm.dox.h:855
*string view_type_owner
Owner of the type of the view if the view is a typed view.
Definition: OracleSqlUtil.qm.dox.h:671
represents an Oracle table
Definition: OracleSqlUtil.qm.dox.h:1429
*string tablespace
Name of the potential tablespace.
Definition: OracleSqlUtil.qm.dox.h:859
*string superview_name
Name of the superview.
Definition: OracleSqlUtil.qm.dox.h:675
bool enabled
True if the trigger is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:708
const COP_SEQ_CURRVAL
const True
const SZ_MAND
const CHAR
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:462
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:490
represents an Oracle procedure
Definition: OracleSqlUtil.qm.dox.h:811
number number(softnumber n)
const COP_YEAR_HOUR
binary binary()
hash< UpdateOperatorInfo > uop_substr(int start, *int count, *hash< UpdateOperatorInfo > nest)
const IOP_SEQ_CURRVAL
const False
*string tablespace
any tablespace for the unique key index
Definition: OracleSqlUtil.qm.dox.h:521
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:518
represents an Oracle view
Definition: OracleSqlUtil.qm.dox.h:662
RangeIterator xrange(int start, int stop, int step=1, auto val)
hash< string, hash< JoinOperatorInfo > > join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
list list(...)
const Float
int index(softstring str, softstring substr, softint pos=0)
const DT_DAY
const Boolean
const SZ_NUM
date microseconds(softint us)
const Binary
*string oid_text
WITH OID clause of the typed view.
Definition: OracleSqlUtil.qm.dox.h:669
bool exists(...)
hash< ColumnOperatorInfo > cop_trunc_date(auto column, string mask)
bool use_index
Flag if is index used.
Definition: OracleSqlUtil.qm.dox.h:857
const COP_YEAR_MONTH
const BLOB
the Oracle specialization for SqlUtil::AbstractDatabase
Definition: OracleSqlUtil.qm.dox.h:882
int byte_size
byte size of the column
Definition: OracleSqlUtil.qm.dox.h:360
const CLOB
const NOTHING
bool same(list l)
string type(auto arg)
const COP_TRUNC_DATE
the base class for Oracle code objects that cannot be renamed in place
Definition: OracleSqlUtil.qm.dox.h:763
represents an Oracle check constraint
Definition: OracleSqlUtil.qm.dox.h:485
represents an Oracle number column
Definition: OracleSqlUtil.qm.dox.h:416
represents an Oracle package
Definition: OracleSqlUtil.qm.dox.h:823
hash< ColumnOperatorInfo > cop_seq(string seq, *string as)
const Int
const COP_YEAR
string string(softstring str, *string enc)
represents an Oracle column
Definition: OracleSqlUtil.qm.dox.h:353
*string type_text
Type clause of the typed view.
Definition: OracleSqlUtil.qm.dox.h:667
OracleDatabase get_database(AbstractDatasource nds, *hash opts)
returns an OracleDatabase object corresponding to the arguments
const COP_CAST
hash< OperatorInfo > op_in()
const DT_MINUTE
hash< ColumnOperatorInfo > cop_seq_currval(string seq, *string as)
const DT_HOUR
*string body_src
package body source
Definition: OracleSqlUtil.qm.dox.h:828
const DefaultUopMap
const COP_YEAR_DAY
*string tablespace
any tablespace for the primary key index
Definition: OracleSqlUtil.qm.dox.h:583
*string view_type
Type of the view if the view is a typed view.
Definition: OracleSqlUtil.qm.dox.h:673
const DT_MONTH
const Object
represents an Oracle sequence
Definition: OracleSqlUtil.qm.dox.h:641
represents an Oracle trigger
Definition: OracleSqlUtil.qm.dox.h:703
hash< OperatorInfo > op_substr(int start, *int count, string text)
OracleTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns an OracleTable object corresponding to the arguments
hash hash(object obj)
bool container_data
Indicates whether the view contains container-specific data.
Definition: OracleSqlUtil.qm.dox.h:677
const COP_SUBSTR
const OracleSchemaDescriptionOptions
oracle-specific schema description keys
Definition: OracleSqlUtil.qm.dox.h:906
const OP_SUBSTR
hash< ColumnOperatorInfo > cop_substr(auto column, int start, *int count)
const SZ_OPT
const IOP_SEQ
represents an Oracle foreign constraint
Definition: OracleSqlUtil.qm.dox.h:457
represents an Oracle type
Definition: OracleSqlUtil.qm.dox.h:785
const DT_YEAR
represents an Oracle primary key
Definition: OracleSqlUtil.qm.dox.h:578
string native_type
the native type of the index (if supported)
Definition: OracleSqlUtil.qm.dox.h:432
string join(string str,...)
const NUMERIC
const Number
represents an Oracle index
Definition: OracleSqlUtil.qm.dox.h:427
const DefaultOpMap
bool char_used
the column uses character semantics
Definition: OracleSqlUtil.qm.dox.h:358
const DT_SECOND
represents an Oracle function
Definition: OracleSqlUtil.qm.dox.h:799
the base class for Oracle code objects
Definition: OracleSqlUtil.qm.dox.h:732