Qore OracleSqlUtilBase Module Reference 1.6
Loading...
Searching...
No Matches
OracleSqlUtilBase.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* OracleSqlUtilBase.qm Copyright 2013 - 2023 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// minimum required Qore version
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
420 OracleTable get_table(AbstractDatasource nds, string nname, *hash opts);
421
422
424 OracleDatabase get_database(AbstractDatasource nds, *hash opts);
425
426
428class OracleSavepointHelper : public AbstractSavepointHelper {
429
430public:
432
436 constructor(AbstractDatasource ds, *string savepoint = 'x' + get_random_string(29))
437 ;
438
439
441protected:
443public:
444
445
447protected:
449public:
450
451
453protected:
455public:
456
457 };
458
461
462public:
464 constructor(string native_type, bool nullable, *hash<auto> options)
465 ;
466
467 };
468
471
472public:
477
479protected:
481public:
482
483
484 constructor(string n, string nt, *string qt, softint sz, bool nul, *string dv, *string cm,
485 bool is_char = False, bool cu = False, softint bs, *int scale)
486 ;
487
488
490
493
494
496
503 list<string> getAddColumnSql(AbstractTable t);
504
505
507
522 list<string> getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
523
524
526
536 string getRenameSql(AbstractTable t, string new_name);
537
538
540 bool equalImpl(AbstractColumn c);
541
542
544
546 string getDdlName(string name);
547
548 };
549
552
553public:
554 constructor(string n, string nt, *string qt, softint sz, bool nul, *string dv, *string cm, softint bs,
555 softint scale = 0) ;
556
557 };
558
561
562public:
565
567 *string tablespace;
568
570 constructor(string n, bool u, hash c, string nt, *string t) ;
571
572
574 string getCreateSql(string table_name, *hash opt);
575
576
578 bool equalImpl(AbstractIndex ix);
579
580
582 string getRenameSql(string table_name, string new_name);
583
584 };
585
588
589public:
592
593 constructor(string n, Columns c, ForeignConstraintTarget t, bool e) ;
594
595
596 string getCreateSql(string table_name, *hash opt);
597
598
599 softlist getRenameSql(string table_name, string new_name);
600
601
603 string getDisableSql(string table_name);
604
605
607 string getEnableSql(string table_name, *hash opt);
608
609 };
610
613
614public:
617
618 constructor(string n, string n_src, bool e = True) ;
619
620
621 string getCreateSql(string table_name, *hash opt);
622
623
624 softlist getRenameSql(string table_name, string new_name);
625
626
628 string getDisableSql(string table_name);
629
630
632 string getEnableSql(string table_name, *hash opt);
633
634 };
635
638
639public:
640protected:
643
645 *string tablespace;
646
647public:
648
649 constructor(string n, hash n_cols, bool e = True, *string ts) ;
650
651
653
670
671
672 bool setIndexBase(string ix);
673
674
677
678
679 string getCreateSql(string table_name, *hash opts);
680
681
682 softlist getRenameSql(string table_name, string new_name);
683
684
686 string getDisableSql(string table_name);
687
688
690 string getEnableSql(string table_name, *hash opt);
691
692
694 bool isEnabled();
695
696
698 *string getTablespace();
699
700 };
701
704
705public:
706protected:
708 *string tablespace;
709
710public:
711
712 constructor();
713
714
715 constructor(string n, *hash c, *string ts) ;
716
717
719
736
737
738 bool setIndexBase(string ix);
739
740
743
744
745 string getCreateSql(string table_name, *hash opts);
746
747
748 softlist getRenameSql(string table_name, string new_name);
749
750
752
754 string getDropSql(string table_name);
755
756
758 string getDisableSql(string table_name);
759
760
762 string getEnableSql(string table_name, *hash opt);
763
764 };
765
768
769public:
771 constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end)
772 ;
773
774
776 string getCreateSql(*hash opt);
777
778
780
784 softlist getRenameSql(string new_name, *hash opt);
785
786 };
787
790
791public:
793 *string type_text;
795 *string oid_text;
799 *string view_type;
804
806 constructor(string n_name, string n_src, *string n_schema, *string n_type_text,
807 *string n_oid_text, *string n_view_type_owner,
808 *string n_view_type, *string n_superview_name,
809 bool n_updatable, bool n_container_data)
810 ;
811
812
814 string getCreateSql(*hash opt);
815
816
818
822 softlist getRenameSql(string new_name, *hash opt);
823
824 };
825
828
829public:
832
833 constructor(string n, string n_src, bool en = True) ;
834
835
836 softlist getCreateSql(string table_name, *hash opt);
837
838
840 bool equalImpl(AbstractFunctionBase t);
841
842
844 softlist getRenameSql(string table_name, string new_name);
845
846
848 softlist getDropSql(string table_name);
849
850 };
851
854
855public:
857
861 constructor(string n, string n_type, string n_src) ;
862
863
865
867 softlist getCreateSql(*hash opt);
868
869
871 bool equalImpl(AbstractFunctionBase t);
872
873
875
879 softlist getRenameSql(string new_name, *hash opt);
880
881 };
882
885
886public:
888
892 constructor(string n, string n_type, string n_src) ;
893
894
896
901 softlist getRenameSql(string new_name, *hash opt);
902
903 };
904
907
908public:
909 constructor(string n_name, string n_src) ;
910
911
913
915 string getDropSql(*hash opt);
916
917 };
918
921
922public:
924
927 constructor(string n, string n_src) ;
928
929 };
930
933
934public:
936
939 constructor(string n, string n_src) ;
940
941 };
942
945
946public:
948 *string body_src;
949
951
955 constructor(string n, string n_src, *string n_body_src) ;
956
957
959 list getCreateSql(*hash opt);
960
961
963 bool equalImpl(AbstractFunctionBase t);
964
965 };
966
969
970public:
976 *string tablespace;
977
979
985 constructor(string n, string n_src, bool n_logging = True, bool n_use_index = True, *string n_tablespace) ;
986
987
989 softlist getCreateSql(*hash opt);
990
991
992 bool equalImpl(AbstractFunctionBase t);
993
994 };
995
998
999public:
1002
1003
1006
1007
1009
1018
1019
1022
1023
1026
1027
1030
1031
1034
1035
1038
1039
1042
1044 constructor(AbstractDatasource nds, *hash opts) ;
1045
1046
1048
1053
1054
1055protected:
1056 list<string> featuresImpl();
1057public:
1058
1059
1060protected:
1061 OracleSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
1062public:
1063
1064
1065protected:
1066 getSchemaName(reference<string> name, reference<string> schema);
1067public:
1068
1069
1070protected:
1071 *AbstractSequence getSequenceImpl(string name);
1072public:
1073
1074
1075protected:
1076 *AbstractView getViewImpl(string name);
1077public:
1078
1079
1080protected:
1081 OracleFunction makeFunctionImpl(string name, string src, *hash opts);
1082public:
1083
1084
1085protected:
1086 OracleProcedure makeProcedureImpl(string name, string src, *hash opts);
1087public:
1088
1089
1090protected:
1091 OraclePackage makePackage(string name, string src, string body, *hash opts);
1092public:
1093
1094
1095protected:
1096 OraclePackage makePackageFromDescription(string name, hash ph, *hash opts);
1097public:
1098
1099
1100protected:
1101 OracleType makeType(string name, string src, *hash opts);
1102public:
1103
1104
1105protected:
1106 OracleMaterializedView makeMaterializedView(string name, string src, bool logging = True, bool use_index = True, *string tablespace, *hash opts);
1107public:
1108
1109
1110protected:
1111 OracleMaterializedView makeMaterializedViewFromDescription(string name, hash mvh, *hash opts);
1112public:
1113
1114
1115protected:
1116 list<auto> getDropSchemaSqlImpl(hash<auto> schema_hash, *hash<auto> opt);
1117public:
1118
1119
1120protected:
1121 list getAlignSqlImpl(hash schema_hash, *hash opt);
1122public:
1123
1124
1125protected:
1126 *OracleFunction getFunctionImpl(string name);
1127public:
1128
1129
1130protected:
1131 *OracleProcedure getProcedureImpl(string name);
1132public:
1133
1134
1137
1138
1140 *OracleType getType(string name);
1141
1142
1145
1146
1147protected:
1148 *string getSource(string type, string name);
1149public:
1150
1151
1152protected:
1153 checkSource(string type, string name, reference<string> src);
1154public:
1155
1156
1158 list<string> listSynonyms();
1159
1160
1162 ListIterator synonymIterator();
1163
1164
1166 list<string> listTypes();
1167
1168
1170 ListIterator typeIterator();
1171
1172
1174 list<string> listPackages();
1175
1176
1178 ListIterator packageIterator();
1179
1180
1183
1184
1187
1188
1189protected:
1190 list<string> listTablesImpl();
1191public:
1192
1193
1194protected:
1195 list<string> listFunctionsImpl();
1196public:
1197
1198
1199protected:
1200 list<string> listProceduresImpl();
1201public:
1202
1203
1204protected:
1205 list<string> listSequencesImpl();
1206public:
1207
1208
1209protected:
1210 list<string> listViewsImpl();
1211public:
1212
1213
1214protected:
1215 list<string> getListIntern(string type);
1216public:
1217
1218
1219protected:
1220 list<string> getListIntern(list<auto> l);
1221public:
1222
1223
1224protected:
1225 string getCreateSqlImpl(list l);
1226public:
1227
1228
1229 static string getCreateSql(list l);
1230
1232protected:
1234public:
1235
1236
1238protected:
1240public:
1241
1242
1244protected:
1246public:
1247
1248
1250protected:
1252public:
1253
1254
1256protected:
1258public:
1259
1260
1262protected:
1263 softint getNextSequenceValueImpl(string name);
1264public:
1265
1266
1268protected:
1269 softint getCurrentSequenceValueImpl(string name);
1270public:
1271
1272
1274protected:
1276public:
1277
1278
1280protected:
1282public:
1283
1284
1286protected:
1288public:
1289
1290
1292
1304 bool rebuildIndexAnalyze(AbstractIndex index, int maxh, int maxleaf);
1305
1306
1308
1320 bool rebuildIndexAnalyze(string name, int maxh, int maxleaf);
1321
1322
1324protected:
1325 bool rebuildIndexImpl(string name, *hash options);
1326public:
1327
1328
1330protected:
1332public:
1333
1334
1336protected:
1338public:
1339
1340
1342protected:
1344public:
1345
1346
1348protected:
1349 reclaimSpaceImpl(*hash options);
1350public:
1351
1352
1354protected:
1356public:
1357
1358
1359protected:
1360 oracleErrorCallback(int ac, string type, string name, *string table, *string new_name, *string info, string sql, hash<ExceptionInfo> ex);
1361public:
1362
1363 };
1364
1366
1369
1370public:
1372 const OraTypeMap = {
1373 "number": ("qore": Type::Number, "size": SZ_NUM, "size_range": (1, 38), "scale_range": (-84, 127)),
1374 "varchar2": {
1375 "qore": Type::String,
1376 "size": SZ_MAND,
1377 "size_range": (1, 4000),
1378 "is_char": True,
1379 "default_size": AbstractColumn::DefaultVarcharSize,
1380 },
1381 "char": {
1382 "qore": Type::String,
1383 "size": SZ_MAND,
1384 "size_range": (1, 4000),
1385 "is_char": True,
1386 "default_size": AbstractColumn::DefaultVarcharSize,
1387 },
1388 "date": ("qore": Type::Date,),
1389 "timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1390 "timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1391 "timestamp with local time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
1392 "interval year to month": ("qore": Type::Date,),
1393 "interval day to second": ("qore": Type::Date,),
1394 "timestamp(0)": ("qore": Type::Date,),
1395 "timestamp(1)": ("qore": Type::Date,),
1396 "timestamp(2)": ("qore": Type::Date,),
1397 "timestamp(3)": ("qore": Type::Date,),
1398 "timestamp(4)": ("qore": Type::Date,),
1399 "timestamp(5)": ("qore": Type::Date,),
1400 "timestamp(6)": ("qore": Type::Date,),
1401 "timestamp(7)": ("qore": Type::Date,),
1402 "timestamp(8)": ("qore": Type::Date,),
1403 "timestamp(9)": ("qore": Type::Date,),
1404 "timestamp(0) with time zone": ("qore": Type::Date,),
1405 "timestamp(1) with time zone": ("qore": Type::Date,),
1406 "timestamp(2) with time zone": ("qore": Type::Date,),
1407 "timestamp(3) with time zone": ("qore": Type::Date,),
1408 "timestamp(4) with time zone": ("qore": Type::Date,),
1409 "timestamp(5) with time zone": ("qore": Type::Date,),
1410 "timestamp(6) with time zone": ("qore": Type::Date,),
1411 "timestamp(7) with time zone": ("qore": Type::Date,),
1412 "timestamp(8) with time zone": ("qore": Type::Date,),
1413 "timestamp(9) with time zone": ("qore": Type::Date,),
1414 "timestamp(0) with local time zone": ("qore": Type::Date,),
1415 "timestamp(1) with local time zone": ("qore": Type::Date,),
1416 "timestamp(2) with local time zone": ("qore": Type::Date,),
1417 "timestamp(3) with local time zone": ("qore": Type::Date,),
1418 "timestamp(4) with local time zone": ("qore": Type::Date,),
1419 "timestamp(5) with local time zone": ("qore": Type::Date,),
1420 "timestamp(6) with local time zone": ("qore": Type::Date,),
1421 "timestamp(7) with local time zone": ("qore": Type::Date,),
1422 "timestamp(8) with local time zone": ("qore": Type::Date,),
1423 "timestamp(9) with local time zone": ("qore": Type::Date,),
1424 "interval year(0) to month": ("qore": Type::Date,),
1425 "interval year(1) to month": ("qore": Type::Date,),
1426 "interval year(2) to month": ("qore": Type::Date,),
1427 "interval year(3) to month": ("qore": Type::Date,),
1428 "interval year(4) to month": ("qore": Type::Date,),
1429 "interval year(5) to month": ("qore": Type::Date,),
1430 "interval year(6) to month": ("qore": Type::Date,),
1431 "interval year(7) to month": ("qore": Type::Date,),
1432 "interval year(8) to month": ("qore": Type::Date,),
1433 "interval year(9) to month": ("qore": Type::Date,),
1434 "interval day(0) to second(0)": ("qore": Type::Date,),
1435 "interval day(0) to second(1)": ("qore": Type::Date,),
1436 "interval day(0) to second(2)": ("qore": Type::Date,),
1437 "interval day(0) to second(3)": ("qore": Type::Date,),
1438 "interval day(0) to second(4)": ("qore": Type::Date,),
1439 "interval day(0) to second(5)": ("qore": Type::Date,),
1440 "interval day(0) to second(6)": ("qore": Type::Date,),
1441 "interval day(0) to second(7)": ("qore": Type::Date,),
1442 "interval day(0) to second(8)": ("qore": Type::Date,),
1443 "interval day(0) to second(9)": ("qore": Type::Date,),
1444 "interval day(1) to second(0)": ("qore": Type::Date,),
1445 "interval day(1) to second(1)": ("qore": Type::Date,),
1446 "interval day(1) to second(2)": ("qore": Type::Date,),
1447 "interval day(1) to second(3)": ("qore": Type::Date,),
1448 "interval day(1) to second(4)": ("qore": Type::Date,),
1449 "interval day(1) to second(5)": ("qore": Type::Date,),
1450 "interval day(1) to second(6)": ("qore": Type::Date,),
1451 "interval day(1) to second(7)": ("qore": Type::Date,),
1452 "interval day(1) to second(8)": ("qore": Type::Date,),
1453 "interval day(1) to second(9)": ("qore": Type::Date,),
1454 "interval day(2) to second(0)": ("qore": Type::Date,),
1455 "interval day(2) to second(1)": ("qore": Type::Date,),
1456 "interval day(2) to second(2)": ("qore": Type::Date,),
1457 "interval day(2) to second(3)": ("qore": Type::Date,),
1458 "interval day(2) to second(4)": ("qore": Type::Date,),
1459 "interval day(2) to second(5)": ("qore": Type::Date,),
1460 "interval day(2) to second(6)": ("qore": Type::Date,),
1461 "interval day(2) to second(7)": ("qore": Type::Date,),
1462 "interval day(2) to second(8)": ("qore": Type::Date,),
1463 "interval day(2) to second(9)": ("qore": Type::Date,),
1464 "clob": ("qore": Type::String,),
1465 "blob": ("qore": Type::Binary,),
1466 "long": ("qore": Type::Binary,),
1467 "raw": ("qore": Type::Binary, "size": SZ_MAND, "size_range": (1, 2000)),
1468 "bfile": ("qore": Type::Binary,),
1469 "binary_float": ("qore": Type::Float,),
1470 "binary_double": ("qore": Type::Float,),
1471 "rowid": ("qore": Type::String,),
1472 "urowid": ("qore": Type::String, "size": SZ_OPT, "size_range": (1, 4000)),
1473 };
1474
1476 const QoreTypeMap = {
1477 "integer": "number",
1478 "float": "number",
1479 "number": "number",
1480 "string": "varchar2",
1481 "date": "timestamp(6)",
1482 "binary": "blob",
1483 SqlUtil::CHAR: "char",
1484 SqlUtil::CLOB: "clob",
1485 SqlUtil::BLOB: "blob",
1486 };
1487
1488 const OraColumnOpts = {
1489 "character_semantics": Type::Boolean,
1490 };
1491
1493
1496 const OraColumnOptions = AbstractTable::ColumnOptions + OraColumnOpts;
1497
1499
1502 const OraColumnDescOptions = AbstractTable::ColumnDescOptions + OraColumnOpts;
1503
1505
1508 const OracleIndexOptions = AbstractTable::IndexOptions + {
1509 "compute_statistics": Type::Boolean,
1510 };
1511
1513
1517 "index": Type::String,
1518 };
1519
1522
1523
1524 const OracleAlignTableOptions = AbstractTable::AlignTableOptions + OracleTableCreationOptions;
1525
1527
1531 const OracleSelectOptions = AbstractTable::SelectOptions + {
1532 "partition": Type::String,
1533 };
1534
1536 const OracleExpressionMap = DefaultExpressionMap + {
1537 OP_SUBSTR: DefaultExpressionMap{OP_SUBSTR} + {
1538 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1539 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1540 AbstractDataProviderTypeMap."string");
1541 string exp1 = info.table.getExpressionArg(\info, role, args[1],
1542 AbstractDataProviderTypeMap."int");
1543 if (!exists args[2]) {
1544 return sprintf("substr(%s,%s)", exp0, exp1);
1545 }
1546 return sprintf("substr(%s,%s,%s)", exp0, exp1,
1547 info.table.getExpressionArg(\info, role, args[2], AbstractDataProviderTypeMap."int"));
1548 },
1549 },
1550 COP_CAST: {
1551 "exp": <DataProviderExpressionInfo>{
1552 "type": DET_Operator,
1553 "label": COP_CAST,
1554 "name": "cast",
1555 "desc": "cast operator",
1556 "symbol": "cast",
1557 "args": (
1558 DataProviderSignatureAnyType,
1559 DataProviderSignatureStringValueType,
1560 DataProviderSignatureOptionalIntValueType,
1561 DataProviderSignatureOptionalIntValueType,
1562 ),
1563 "return_type": AbstractDataProviderTypeMap."any",
1564 },
1565 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1566 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1567 AbstractDataProviderTypeMap."any");
1568 string name = QoreTypeMap{args[1]} ?? args[1];
1569 *hash<auto> desc = OraTypeMap{name};
1570 string sql = sprintf ("cast (%s as %s", exp0, name);
1571 if (desc.size == SZ_MAND) {
1572 if (!exists args[1] && !exists desc.size_range)
1573 throw "OPERATOR-ERROR", sprintf ("cast operator missing size for type %s",
1574 name);
1575 sql += sprintf("(%d)", args[1] ?? desc.size_range[1]);
1576 } else if (desc.size == SZ_NUM && exists args[1]) {
1577 sql += sprintf("(%d", args[1]);
1578 sql += exists args[2] ? sprintf(",%d)", args[2]) : ")";
1579 } else if (desc.size == SZ_OPT && exists args[1]) {
1580 sql += sprintf("(%d)", args[1]);
1581 }
1582 sql += ")";
1583 return sql;
1584 },
1585 },
1586 COP_YEAR: {
1587 "exp": <DataProviderExpressionInfo>{
1588 "type": DET_Operator,
1589 "label": COP_YEAR,
1590 "name": COP_YEAR,
1591 "desc": "returns the year component of a date as a string (ex: `2022`)",
1592 "symbol": COP_YEAR,
1593 "args": (
1594 DataProviderSignatureDateType,
1595 ),
1596 "return_type": AbstractDataProviderTypeMap."string",
1597 },
1598 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1599 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1600 AbstractDataProviderTypeMap."date");
1601 return sprintf("to_char(%s, 'YYYY')", exp0);
1602 }
1603 },
1604 COP_YEAR_MONTH: {
1605 "exp": <DataProviderExpressionInfo>{
1606 "type": DET_Operator,
1607 "label": COP_YEAR_MONTH,
1608 "name": COP_YEAR_MONTH,
1609 "desc": "returns the year and month components of a date as a string (ex: `2022-06`)",
1610 "symbol": COP_YEAR_MONTH,
1611 "args": (
1612 DataProviderSignatureDateType,
1613 ),
1614 "return_type": AbstractDataProviderTypeMap."string",
1615 },
1616 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1617 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1618 AbstractDataProviderTypeMap."date");
1619 return sprintf("to_char(%s, 'YYYY-MM')", exp0);
1620 }
1621 },
1622 COP_YEAR_DAY: {
1623 "exp": <DataProviderExpressionInfo>{
1624 "type": DET_Operator,
1625 "label": COP_YEAR_DAY,
1626 "name": COP_YEAR_DAY,
1627 "desc": "returns the year, month, and day components of a date as a string (ex: `2022-06-29`)",
1628 "symbol": COP_YEAR_DAY,
1629 "args": (
1630 DataProviderSignatureDateType,
1631 ),
1632 "return_type": AbstractDataProviderTypeMap."string",
1633 },
1634 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1635 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1636 AbstractDataProviderTypeMap."date");
1637 return sprintf("to_char(%s, 'YYYY-MM-DD')", exp0);
1638 }
1639 },
1640 COP_YEAR_HOUR: {
1641 "exp": <DataProviderExpressionInfo>{
1642 "type": DET_Operator,
1643 "label": COP_YEAR_HOUR,
1644 "name": COP_YEAR_HOUR,
1645 "desc": "returns the year, month, day, and hour components of a date as a string "
1646 "(ex: `2022-06-29 15`)",
1647 "symbol": COP_YEAR_HOUR,
1648 "args": (
1649 DataProviderSignatureDateType,
1650 ),
1651 "return_type": AbstractDataProviderTypeMap."string",
1652 },
1653 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1654 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1655 AbstractDataProviderTypeMap."date");
1656 return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", exp0);
1657 }
1658 },
1659 COP_TRUNC_DATE: {
1660 "exp": <DataProviderExpressionInfo>{
1661 "type": DET_Operator,
1662 "label": COP_TRUNC_DATE,
1663 "name": COP_TRUNC_DATE,
1664 "desc": "truncates the given date to the given resolution; args: date, string code: Y: year, "
1665 "M: month, D: day, H: hour, m: minute, S: second",
1666 "symbol": COP_TRUNC_DATE,
1667 "args": (
1668 DataProviderSignatureDateType,
1669 DataProviderSignatureStringValueType,
1670 ),
1671 "return_type": AbstractDataProviderTypeMap."date",
1672 },
1673 "code": string sub(reference<hash<QueryInfo>> info, int role, list<auto> args) {
1674 *string str = OracleTruncDate{args[1]};
1675 if (!str && !OracleTruncDate.hasKey(args[1])) {
1676 throw "TRUNC-DATE-ERROR", sprintf("unknown date truncation format argument %y; "
1677 "supported date format arguments: %y", args[1], keys OracleTruncDate);
1678 }
1679 string exp0 = info.table.getExpressionArg(\info, role, args[0],
1680 AbstractDataProviderTypeMap."date");
1681 if (str) {
1682 return sprintf("trunc(%s, %s)", exp0, str);
1683 }
1684 // for timestamps
1685 return sprintf("cast (%s as date)", exp0);
1686 },
1687 },
1688 OP_IN: {
1689 "exp": <DataProviderExpressionInfo>{
1690 "type": DET_Operator,
1691 "label": OP_IN,
1692 "name": OP_IN,
1693 "desc": "returns True if the first value is in the list of following values",
1694 "symbol": OP_IN,
1695 "args": (
1696 DataProviderSignatureAnyType,
1697 DataProviderSignatureAnyType,
1698 ),
1699 "varargs": True,
1700 "return_type": AbstractDataProviderTypeMap."bool",
1701 },
1702 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1703%ifndef NO_ORACLE
1704 auto val = shift args;
1705 # Qorus bug #989 SqlUtil: oracle op_in can fail in large amount of input elements
1706 # There is no support for CLOBs in WHERE clause in Oracle at all.
1707 # Binding large strings (over 4000 chars is performed by a CLOB in Qore driver.
1708 # Result of op_in operator can be "ORA-00932: inconsistent datatypes" if is
1709 # the list longer or if it contains large items with:
1710 # return cn + " in (select regexp_substr(%v,'[^,]+', 1, level) from dual connect by
1711 # regexp_substr(%v, '[^,]+', 1, level) is not null)";
1712
1713 # determine list members type. Let's assume the 1st non NULL/NOTHING
1714 # element gives the type code for all elements.
1715 ListIterator it(args);
1716 # get list type code
1717 int ltype;
1718 while (it.next()) {
1719 switch (it.getValue().typeCode()) {
1720 case NT_NULL:
1721 case NT_NOTHING:
1722 continue;
1723 case NT_DATE:
1724 case NT_INT:
1725 case NT_FLOAT:
1726 case NT_NUMBER:
1727 case NT_STRING:
1728 ltype = it.getValue().typeCode();
1729 break;
1730 default:
1731 throw "ORACLE-IN-OPERATOR-ERROR", sprintf("the \"in\" operator unexpected list "
1732 "element type: %s; only simple types are supported", it.getValue().type());
1733 }
1734 if (ltype) {
1735 break;
1736 }
1737 }
1738
1739 # Split long array to chunks of no more than 32767 elements due to Oracle limitation
1740 # "ORA-22165: OCI-22165: given index [32767] must be in the range of [0] to [32766]"
1741 int count;
1742 while (args) {
1743 ++count;
1744 list<auto> chunk = extract args, 0, 32767;
1745
1746 # Bind to Oracle by expected type
1747 switch (ltype) {
1748 case NT_DATE:
1749 info.args += bindOracleCollection("SYS.ODCIDATELIST", chunk);
1750 break;
1751 case NT_INT:
1752 case NT_FLOAT:
1753 case NT_NUMBER:
1754 info.args += bindOracleCollection("SYS.ODCINUMBERLIST", chunk);
1755 break;
1756 default:
1757 info.args += bindOracleCollection("SYS.ODCIVARCHAR2LIST", chunk);
1758 }
1759 }
1760
1761 if (count) {
1762 string exp0 = info.table.getExpressionArg(\info, role, val,
1763 AbstractDataProviderTypeMap."date");
1764 return exp0 + " in (" + (map "select column_value from table(%v)",
1765 xrange(count)).join(" union all ") + ")";
1766 } else {
1767 return "1 != 1";
1768 }
1769%else
1770 throw "MISSING-ORACLE-DRIVER", "requires the oracle driver";
1771%endif
1772 },
1773 },
1774 COP_SEQ: {
1775 "exp": <DataProviderExpressionInfo>{
1776 "type": DET_Operator,
1777 "label": COP_SEQ,
1778 "name": COP_SEQ,
1779 "desc": "returns the next value in the given sequence; args: sequence name",
1780 "symbol": COP_SEQ,
1781 "args": (
1782 DataProviderSignatureStringValueType,
1783 ),
1784 "return_type": AbstractDataProviderTypeMap."int",
1785 },
1786 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1787 return sprintf("%s.nextval", args[0]);
1788 }
1789 },
1790 COP_SEQ_CURRVAL: {
1791 "exp": <DataProviderExpressionInfo>{
1792 "type": DET_Operator,
1793 "label": COP_SEQ_CURRVAL,
1794 "name": COP_SEQ_CURRVAL,
1795 "desc": "returns the current value in the given sequence; args: sequence name",
1796 "symbol": COP_SEQ_CURRVAL,
1797 "args": (
1798 DataProviderSignatureStringValueType,
1799 ),
1800 "return_type": AbstractDataProviderTypeMap."int",
1801 },
1802 "code": string sub (reference<hash<QueryInfo>> info, int role, list<auto> args) {
1803 return sprintf("%s.currval", args[0]);
1804 }
1805 },
1806 };
1807
1809 const OracleOpMap = ...;
1810
1811
1813 const OracleCopMap = ...;
1814
1815
1817 const OracleTruncDate = ...;
1818
1819
1821 const OracleIopMap = ...;
1822
1823
1825 const OracleUopMap = ...;
1826
1827
1830 "rowid": True,
1831 "rownum": True,
1832 "object_id": True,
1833 "object_value": True,
1834 "ora_rowscn": True,
1835 };
1836
1837protected:
1838 // schema name
1839 string schema;
1840
1841 // tablespace name
1842 *string tablespace;
1843
1844 // is the table read only?
1845 bool readonly;
1846
1847 // table comment
1848 *string comment;
1849
1850 // dblink
1851 *string dblink;
1852
1853 // Oracle server major version
1854 int ora_major;
1855
1856 // helper flag to indicate if is the OracleTable real table or a view
1857 bool m_isView = False;
1858
1859 // oraclesqlutilbase: allow to use DBA_* views instead of ALL_* if possible #2418
1860 // An internal cache to find the highest priority available
1861 // system dictionary object. Priority: DBA > ALL
1862 hash<string, string> m_sys_views = {
1863 "dba_col_comments" : "all_col_comments",
1864 "dba_cons_columns" : "all_cons_columns",
1865 "dba_constraints" : "all_constraints",
1866 "dba_db_links" : "all_db_links",
1867 "dba_ind_columns" : "all_ind_columns",
1868 "dba_ind_expressions" : "all_ind_expressions",
1869 "dba_indexes" : "all_indexes",
1870 "dba_objects" : "all_objects",
1871 "dba_sequences" : "all_sequences",
1872 "dba_synonyms" : "all_synonyms",
1873 "dba_tab_columns" : "all_tab_columns",
1874 "dba_tab_comments" : "all_tab_comments",
1875 "dba_tables" : "all_tables",
1876 "dba_triggers" : "all_triggers",
1877 "dba_views" : "all_views",
1878 };
1879
1880public:
1881
1882 constructor(AbstractDatasource nds, string nname, *hash opts) ;
1883
1884
1885protected:
1886 introspectSystemViews();
1887public:
1888
1889
1890 // oraclesqlutil: allow to use DBA_* views instead of ALL_* if possible #2418
1891 // get the most appropriate system catalogue/dictinary view available
1892protected:
1893 string systemView(string name);
1894public:
1895
1896
1897protected:
1898 bool checkExistenceImpl();
1899public:
1900
1901
1902protected:
1903 setTableInfoIntern();
1904public:
1905
1906
1908 string getSqlName();
1909
1910
1912 bool isView();
1913
1914
1915protected:
1916 hash<auto> setSchemaTable();
1917public:
1918
1919
1920protected:
1921 setDblinkSchema();
1922public:
1923
1924
1925 // Oracle has supprt for unlimitted synonym loops. There
1926 // can be mo relevels of synonyms before the real object
1927 // is listed.
1928protected:
1929 *hash resolveSynonym(string s_owner, string s_name);
1930public:
1931
1932
1933protected:
1934 hash<auto> setTable();
1935public:
1936
1937
1938protected:
1939 string getUserSchema();
1940public:
1941
1942
1943protected:
1944 string getDBString();
1945public:
1946
1947
1950
1951
1954
1955
1957 *string getComment();
1958
1959
1960 bool readOnly();
1961
1962
1963protected:
1964 hash<auto> getColumnOptions();
1965public:
1966
1967
1968protected:
1969 hash<auto> getColumnDescOptions();
1970public:
1971
1972
1974protected:
1975 hash<auto> getSelectOptions();
1976public:
1977
1978
1980
1982protected:
1983 bool optimizedLimit(*hash<auto> qh);
1984public:
1985
1986
1987protected:
1988 insertLimitOptimizerHint(hash<auto> qh, reference<string> sql);
1989public:
1990
1991
1992 private doSelectOrderByWithOffsetSqlUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql,
1993 list<auto> coll) {
1994 // Oracle 12c+ supports limit (fetch) and offset
1995 softint limit = info.query_hash.limit ?? 0;
1996 softint offset = info.query_hash.offset ?? 0;
1997 if (optimizedLimit(info.query_hash));
1998
1999
2000 list<auto> ce = getOrderByListUnlocked(info, coll);
2001 string sort = foldl $1 + ", " + $2, ce;
2002 // http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
2003 // /*+ first_rows(n) */ is an optimizer hint that we want the first rows as fast as possible
2004 // NOTE: the subquery is necessary because the ORDER BY clause is enforced *after* the ROWNUM
2005 // is calculated; see:
2006 // - https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/ROWNUM-Pseudocolumn.html#GUID-2E40EC12-3FCF-4A4F-B5F2-6BC669021726
2007 // - https://stackoverflow.com/questions/15091849/how-to-use-oracle-order-by-and-rownum-correctly/15091900
2008 sql = sprintf("select * from (select /*+ first_rows(%d) */ a.*, rownum rnum from (%s order by %s%s) a "
2009 "where rownum <= %v%s) where rnum > %v", limit, sql, sort, info.query_hash.desc ? " desc" : "");
2010 if (offset);
2011
2012 info.args += limit;
2013 info.args += offset;
2014 }
2015
2017protected:
2018 doSelectLimitOnlyUnlockedImpl(reference<hash<QueryInfo>> info, reference<string> sql);
2019public:
2020
2021
2022protected:
2023 Columns describeImpl();
2024public:
2025
2026
2027protected:
2028 OraclePrimaryKey getPrimaryKeyImpl();
2029public:
2030
2031
2032protected:
2033 Indexes getIndexesImpl();
2034public:
2035
2036
2037protected:
2038 ForeignConstraints getForeignConstraintsImpl(*hash opts);
2039public:
2040
2041
2042protected:
2043 Constraints getConstraintsImpl();
2044public:
2045
2046
2047protected:
2048 string getSelectSqlName(*hash qh);
2049public:
2050
2051
2052protected:
2053 Triggers getTriggersImpl();
2054public:
2055
2056
2057 string getCreateTableSqlImpl(*hash opt);
2058
2059
2061 hash<auto> getExpressionMap();
2062
2063
2066
2067
2068protected:
2069 *list getCreateMiscSqlImpl(*hash opt, bool cache);
2070public:
2071
2072
2073protected:
2074 string getCreateSqlImpl(list l);
2075public:
2076
2077
2078protected:
2079 string getRenameSqlImpl(string new_name);
2080public:
2081
2082
2083protected:
2084 AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
2085public:
2086
2087
2088protected:
2089 AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
2090public:
2091
2092
2093protected:
2094 AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
2095public:
2096
2097
2098protected:
2099 AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
2100public:
2101
2102
2103protected:
2104 AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
2105public:
2106
2107
2108protected:
2109 AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
2110public:
2111
2112
2113protected:
2114 AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
2115public:
2116
2117
2118protected:
2119 bool tryInsertImpl(string sql, hash<auto> row);
2120public:
2121
2122
2124
2126protected:
2127 bool isDuplicateRowErrorImpl(hash<ExceptionInfo> ex);
2128public:
2129
2130
2131protected:
2132 *list getAlignSqlImpl(AbstractTable t, *hash opt);
2133public:
2134
2135
2136protected:
2137 hash<auto> getQoreTypeMapImpl();
2138public:
2139
2140
2141protected:
2142 hash<auto> getTypeMapImpl();
2143public:
2144
2145
2146protected:
2147 hash<auto> getIndexOptions();
2148public:
2149
2150
2151protected:
2152 hash<auto> getConstraintOptions();
2153public:
2154
2155
2156protected:
2157 hash<auto> getTableCreationOptions();
2158public:
2159
2160
2161protected:
2162 hash<auto> getAlignTableOptions();
2163public:
2164
2165
2167protected:
2169public:
2170
2171
2173protected:
2175public:
2176
2177
2179protected:
2181public:
2182
2183
2185protected:
2186 *hash<auto> getPseudoColumnHash();
2187public:
2188
2189
2191protected:
2192 *string getSqlValueImpl(auto v);
2193public:
2194
2195
2197 string getColumnSqlName(string col);
2198
2199
2201 list getColumnSqlNames(softlist cols);
2202
2203
2205
2208 string getBaseType();
2209
2210
2212 code getBulkUpsertClosure(hash example_row, int upsert_strategy = AbstractTable::UpsertAuto, *hash opt);
2213
2214
2216 code getUpsertClosure(hash<auto> row, int upsert_strategy = UpsertAuto, *hash opt);
2217
2218
2220protected:
2221 code getUpsertInsertOnly(Columns cols, hash<auto> row, *hash opt);
2222public:
2223
2224
2226protected:
2227 code getUpsertUpdateOnly(Columns cols, hash<auto> row, *hash opt);
2228public:
2229
2230
2233
2234
2236
2239
2240
2242protected:
2244public:
2245
2246
2247protected:
2248 *hash doReturningImpl(hash<auto> opt, reference<string> sql, list<auto> args);
2249public:
2250
2251
2252protected:
2253 bool emptyImpl();
2254public:
2255
2256
2257protected:
2258 setupTableImpl(hash<auto> desc, *hash<auto> opt);
2259public:
2260
2261
2263protected:
2265public:
2266
2267
2269protected:
2271public:
2272
2273
2275protected:
2277public:
2278
2279
2281protected:
2282 copyImpl(AbstractTable old);
2283public:
2284
2285
2287protected:
2288 AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash<auto> options);
2289public:
2290
2291
2293
2297protected:
2298 AbstractSavepointHelper getSavepointHelperImpl(*string savepoint);
2299public:
2300
2301 };
2302};
represents an Oracle check constraint
Definition: OracleSqlUtilBase.qm.dox.h:612
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtilBase.qm.dox.h:616
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
the base class for Oracle code objects
Definition: OracleSqlUtilBase.qm.dox.h:853
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the object in the database
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
softlist getCreateSql(*hash opt)
returns a string that can be used to create the object in the database
the base class for Oracle code objects that cannot be renamed in place
Definition: OracleSqlUtilBase.qm.dox.h:884
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the object in the database
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
represents an Oracle column
Definition: OracleSqlUtilBase.qm.dox.h:470
list< string > getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt)
returns a list of sql strings that can be used to modify the column to the new definition
list< string > getAddColumnSql(AbstractTable t)
returns a list of sql strings that can be used to add the column to an existing table
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
string getNativeTypeString()
returns the string describing the native type that can be used in SQL
string getDdlName(string name)
returns the column name with quoting in case the column name is a reserved word
int byte_size
byte size of the column
Definition: OracleSqlUtilBase.qm.dox.h:476
constructor()
empty constructor for subclasses
bool char_used
the column uses character semantics
Definition: OracleSqlUtilBase.qm.dox.h:474
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
the Oracle specialization for SqlUtil::AbstractDatabase
Definition: OracleSqlUtilBase.qm.dox.h:997
int getPhysicalSizeImpl()
SqlUtil::AbstractDatabase::getPhysicalSize()
ListIterator packageIterator()
returns an iterator listing the string package names in the database
const OracleMaterializedViewDescriptionOptions
oracle-specific materialized view description options
Definition: OracleSqlUtilBase.qm.dox.h:1025
softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
const OracleReservedWords
hash of reserved words
Definition: OracleSqlUtilBase.qm.dox.h:1029
bool rebuildIndexImpl(string name, *hash options)
rebuild index implementation. See SqlUtil::AbstractDatabase::rebuildIndex()
list< string > listSynonyms()
returns a list of string synonym names in the database
int getMaximumPrecision()
Returns the maximum precision for numeric or decimal columns.
bool supportsPackagesImpl()
returns True if the database supports packages
*OraclePackage getPackage(string name)
returns an OraclePackage object for the package name given or NOTHING if the object does not exist or...
ListIterator synonymIterator()
returns an iterator listing the string synonym names in the database
*OracleType getType(string name)
returns an OracleType object for the package name given or NOTHING if the object does not exist or is...
list< string > listMaterializedViews()
returns a list of string materialized view names in the database
bool supportsSequencesImpl()
returns True if the database supports sequences
const OracleAlignSchemaOptions
oracle-specific schema description / alignment options
Definition: OracleSqlUtilBase.qm.dox.h:1005
bool rebuildIndexAnalyze(string name, int maxh, int maxleaf)
analyze index with ALTER INDEX ANAYZE. Then it checks INDEX_STATS for advices to rebuild.
reclaimSpaceImpl(*hash options)
reclaim space implementation. See SqlUtil::AbstractDatabase::reclaimSpace()
list< string > listTypes()
returns a list of string type names in the database
const OracleSchemaDescriptionOptions
oracle-specific schema description keys
Definition: OracleSqlUtilBase.qm.dox.h:1017
hash< auto > getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
const OracleComputeStatisticsOptions
Options for computeStatistics()
Definition: OracleSqlUtilBase.qm.dox.h:1037
hash< auto > getRebuildIndexOptions()
returns driver-specific options to the base abstract class
computeStatisticsImpl(*hash options)
compute statistics implementation. See SqlUtil::AbstractDatabase::computeStatistics()
constructor(AbstractDatasource nds, *hash opts)
creates the object from the arguments given
const OracleMaxPrecision
MAximum precision for Oracle NUMBER columns.
Definition: OracleSqlUtilBase.qm.dox.h:1041
hash< auto > getCreationOptions()
returns driver-specific options to the base abstract class
bool supportsTypesImpl()
returns True if the database supports named types
ListIterator materializedViewIterator()
returns an iterator listing the string materialized view names in the database
const OraclePackageDescriptionOptions
oracle-specific package description options
Definition: OracleSqlUtilBase.qm.dox.h:1021
*OracleMaterializedView getMaterializedView(string name)
returns an OracleMaterializedView object for the package name given or NOTHING if the object does not...
hash< auto > getAlignSchemaOptions()
returns driver-specific options to the base abstract class
bool rebuildIndexAnalyze(AbstractIndex index, int maxh, int maxleaf)
analyze index with ALTER INDEX ANAYZE. Then it checks INDEX_STATS for advices to rebuild.
const OracleCreationOptions
oracle-specific generic creation options
Definition: OracleSqlUtilBase.qm.dox.h:1001
ListIterator typeIterator()
returns an iterator listing the string type names in the database
softint getCurrentSequenceValueImpl(string name)
returns the last value issued for the given sequence in the current session
hash< auto > getComputeStatisticsOptions()
returns driver-specific options to the base abstract class
const OracleRebuildIndexOptions
Options for rebuildIndex()
Definition: OracleSqlUtilBase.qm.dox.h:1033
computeStatisticsTablesImpl(*hash options)
compute statistics for table(s) - a helper method
computeStatisticsSchemaImpl(*hash options)
compute statistics for schema - a helper method
list< string > listPackages()
returns a list of string package names in the database
represents an Oracle foreign constraint
Definition: OracleSqlUtilBase.qm.dox.h:587
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtilBase.qm.dox.h:591
represents an Oracle function
Definition: OracleSqlUtilBase.qm.dox.h:920
constructor(string n, string n_src)
creates the object from the arguments passed
represents an Oracle index
Definition: OracleSqlUtilBase.qm.dox.h:560
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
string native_type
the native type of the index (if supported)
Definition: OracleSqlUtilBase.qm.dox.h:564
constructor(string n, bool u, hash c, string nt, *string t)
creates the object from the arguments
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
*string tablespace
the tablespace name of the index (if supported)
Definition: OracleSqlUtilBase.qm.dox.h:567
represents an Oracle materialized view
Definition: OracleSqlUtilBase.qm.dox.h:968
*string tablespace
Name of the potential tablespace.
Definition: OracleSqlUtilBase.qm.dox.h:976
bool use_index
Flag if is index used.
Definition: OracleSqlUtilBase.qm.dox.h:974
bool logging
Flag if is loggign mode used.
Definition: OracleSqlUtilBase.qm.dox.h:972
constructor(string n, string n_src, bool n_logging=True, bool n_use_index=True, *string n_tablespace)
creates the object from the arguments passed
softlist getCreateSql(*hash opt)
returns a string that can be used to create the object in the database
represents an Oracle number column
Definition: OracleSqlUtilBase.qm.dox.h:551
the data type for Oracle NUMBER columns
Definition: OracleSqlUtilBase.qm.dox.h:460
constructor(string native_type, bool nullable, *hash< auto > options)
creates the object
represents an Oracle package
Definition: OracleSqlUtilBase.qm.dox.h:944
*string body_src
package body source
Definition: OracleSqlUtilBase.qm.dox.h:948
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
constructor(string n, string n_src, *string n_body_src)
creates the object from the arguments passed
list getCreateSql(*hash opt)
returns a string that can be used to create the package in the database
represents an Oracle primary key
Definition: OracleSqlUtilBase.qm.dox.h:703
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
*string tablespace
any tablespace for the primary key index
Definition: OracleSqlUtilBase.qm.dox.h:708
OracleColumn memberGate(string k)
returns the OracleColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database
clearIndex()
clears any index base for the constraint
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
represents an Oracle procedure
Definition: OracleSqlUtilBase.qm.dox.h:932
constructor(string n, string n_src)
creates the object from the arguments passed
Oracle savepoint helper.
Definition: OracleSqlUtilBase.qm.dox.h:428
deleteSavepointImpl()
Deletes the savepoint.
createSavepointImpl()
Creates the savepoint.
rollbackImpl()
Rolls back to the savepoint.
constructor(AbstractDatasource ds, *string savepoint='x'+get_random_string(29))
Creates the object.
represents an Oracle sequence
Definition: OracleSqlUtilBase.qm.dox.h:767
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the sequence in the database
represents an Oracle table
Definition: OracleSqlUtilBase.qm.dox.h:1368
hash< auto > getSelectOptions()
override in subclasses to return driver-specific options
AbstractDataProviderType getNumericTypeImpl(string native_type, bool nullable, *hash< auto > options)
returns the type for number / numeric columns for the database so that data conversions can be handle...
hash< auto > getColumnOperatorMapImpl()
returns the column operator map for this object
*string getComment()
returns any table comment or NOTHING if none is known
copyImpl(AbstractTable old)
db-specific copy actions
const OracleTruncDate
Map SqlUtil::cop_trunc_date() constants to Oracle internal masks.
Definition: OracleSqlUtilBase.qm.dox.h:1817
const OracleCopMap
column operator specializations for Oracle
Definition: OracleSqlUtilBase.qm.dox.h:1813
string getSchemaName()
returns the schema name
code getUpsertUpdateOnly(Columns cols, hash< auto > row, *hash opt)
high-performance "update only" upsert supporting bulk DML
*string getSqlValueImpl(auto v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
const OracleSelectOptions
Oracle select options.
Definition: OracleSqlUtilBase.qm.dox.h:1531
*hash< auto > getPseudoColumnHash()
returns a hash of valid pseudocolumns
bool asteriskRequiresPrefix()
returns True if the database requires a wildcard "*" to be prefixed with the table name when it appea...
bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
const OracleIopMap
a hash of default value operator descriptions for Oracle
Definition: OracleSqlUtilBase.qm.dox.h:1821
const OracleConstraintOptions
Oracle-specific constraint options.
Definition: OracleSqlUtilBase.qm.dox.h:1516
AbstractSavepointHelper getSavepointHelperImpl(*string savepoint)
get DB-specific savepoint helper
const OraTypeMap
maps oracle type names to type descriptions
Definition: OracleSqlUtilBase.qm.dox.h:1372
const OraColumnDescOptions
Oracle-specific column options.
Definition: OracleSqlUtilBase.qm.dox.h:1502
const OraclePseudoColumnHash
a hash of valid pseudocolumns
Definition: OracleSqlUtilBase.qm.dox.h:1829
const OracleOpMap
where operator specializations for Oracle
Definition: OracleSqlUtilBase.qm.dox.h:1809
string getSqlName()
returns the schema and table name in dot notation
*string getTablespaceName()
returns the data tablespace name for the table if any or NOTHING if none is known
bool isDuplicateRowErrorImpl(hash< ExceptionInfo > ex)
Returns True if the exception was raised because of a duplicate row / key error.
bool bindEmptyStringsAsNull()
returns True because Oracle treats empty strings like NULL on insert
hash< auto > getExpressionMap()
Returns the expression map for Oracle.
const OracleExpressionMap
Oracle Expression map.
Definition: OracleSqlUtilBase.qm.dox.h:1536
hash< auto > getRawUpdateOperatorMap()
returns the raw (default) update operator map for this object
code getUpsertClosure(hash< auto > row, int upsert_strategy=UpsertAuto, *hash opt)
returns a closure for performing upserts; if the upsert_strategy argument is UpsertInsertFirst or Ups...
bool optimizedLimit(*hash< auto > qh)
Returns True if the current connection supports optimized limit option handling.
const OraColumnOptions
Oracle-specific column options.
Definition: OracleSqlUtilBase.qm.dox.h:1496
hash< auto > getInsertOperatorMap()
returns the insert operator map for this object
bool isView()
This method can change itself or disappear in the near future. Do not use it.
list getColumnSqlNames(softlist cols)
returns a list of column names for use in SQL strings; subclasses can process the argument list in ca...
const OracleUopMap
a hash of default update operator definitions for Oracle
Definition: OracleSqlUtilBase.qm.dox.h:1825
doSelectLimitOnlyUnlockedImpl(reference< hash< QueryInfo > > info, reference< string > sql)
processes a string for use in SQL select statements when there is a "limit" argument,...
code getUpsertInsertOnly(Columns cols, hash< auto > row, *hash opt)
high-performance "insert only" upsert supporting bulk DML
bool supportsTablespacesImpl()
returns True if the database support tablespaces
const OracleIndexOptions
Oracle-specific index options.
Definition: OracleSqlUtilBase.qm.dox.h:1508
bool hasArrayBind()
returns True because the oracle driver supports array binds / bulk DML operations
const OracleTableCreationOptions
Oracle table creation options.
Definition: OracleSqlUtilBase.qm.dox.h:1521
string getColumnSqlName(string col)
returns the column name for use in SQL strings; subclasses can return a special string in case the co...
const QoreTypeMap
maps qore type names to an oracle type
Definition: OracleSqlUtilBase.qm.dox.h:1476
hash< auto > getWhereOperatorMap()
returns the "where" operator map for Oracle
string getBaseType()
returns the base type of the underlying object (either "table" or "view")
bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
code getBulkUpsertClosure(hash example_row, int upsert_strategy=AbstractTable::UpsertAuto, *hash opt)
Oracle always supports bulk merging.
represents an Oracle trigger
Definition: OracleSqlUtilBase.qm.dox.h:827
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
bool enabled
True if the trigger is enabled, False if not
Definition: OracleSqlUtilBase.qm.dox.h:831
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
represents an Oracle type
Definition: OracleSqlUtilBase.qm.dox.h:906
string getDropSql(*hash opt)
returns a string that can be used to drop the type from the database
represents an Oracle unique constraint
Definition: OracleSqlUtilBase.qm.dox.h:637
bool isEnabled()
returns True if the constraint is enabled, False if not
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database
clearIndex()
clears any index base for the constraint
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtilBase.qm.dox.h:642
*string getTablespace()
returns the tablespace name used for this constraint, if known
*string tablespace
any tablespace for the unique key index
Definition: OracleSqlUtilBase.qm.dox.h:645
OracleColumn memberGate(string k)
returns the OracleColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception
represents an Oracle view
Definition: OracleSqlUtilBase.qm.dox.h:789
*string view_type_owner
Owner of the type of the view if the view is a typed view.
Definition: OracleSqlUtilBase.qm.dox.h:797
constructor(string n_name, string n_src, *string n_schema, *string n_type_text, *string n_oid_text, *string n_view_type_owner, *string n_view_type, *string n_superview_name, bool n_updatable, bool n_container_data)
creates the object from the arguments
*string type_text
Type clause of the typed view.
Definition: OracleSqlUtilBase.qm.dox.h:793
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
softlist getRenameSql(string new_name, *hash opt)
returns a string that can be used to rename the view in the database
*string oid_text
WITH OID clause of the typed view.
Definition: OracleSqlUtilBase.qm.dox.h:795
*string superview_name
Name of the superview.
Definition: OracleSqlUtilBase.qm.dox.h:801
*string view_type
Type of the view if the view is a typed view.
Definition: OracleSqlUtilBase.qm.dox.h:799
bool container_data
Indicates whether the view contains container-specific data.
Definition: OracleSqlUtilBase.qm.dox.h:803
cache(*hash< auto > opts)
const CLOB
const BLOB
const CHAR
the OracleSqlUtilBase namespace contains all the objects in the OracleSqlUtilBase module
Definition: OracleSqlUtilBase.qm.dox.h:418
OracleTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns an OracleTable object corresponding to the arguments
OracleDatabase get_database(AbstractDatasource nds, *hash opts)
returns an OracleDatabase object corresponding to the arguments