All Classes Namespaces Functions Variables Groups Pages
OracleSqlUtil.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file OracleSqlUtil.qm Qore user module for working with Oracle SQL data
/* OracleSqlUtil.qm Copyright 2013 - 2014 Qore Technologies, sro
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.8 or better
// requires the SqlUtil module
// requires the Util module
// don't use "$" signs for variables and class members, assume local variable scope
// require type definitions everywhere
// enable all warnings
/* Version History
* 2013-10-04 v1.0: David Nichols <david@qore.org>
+ the initial version of the OracleSqlUtil module
*/
a.*, rownum rnum from (select * from schema.table where type = %v order by type) a where rownum <= %v) where rnum > %v", ("user", 300, 200));
@endcode
note that the following simpler SQL is generated for Oracle 12c+ servers:
@code
$ds.vselectRows("select * from schema.table where type = %v order by type offset %v rows fetch next %v rows only", ("user", 200, 100));
@endcode
@subsection ora_in_operator IN Operator on Oracle
In order to avoid dynamic SQL and better manage the server's shared pool (in particular, the number of parsed statements), the %OracleSqlUtil
module uses bind by value with the SQL \c IN operator.
For example, the following query:
@code
my *hash $q = $table.select(("where": ("col1": op_in(1, 2, 3, 4))));
@endcode
Results in the equivalent of the following SQL:
@code
my *hash $q = $ds.select("select * from schema.table where col1 in (select regexp_substr(%v,'[^,]+', 1, level) from dual connect by regexp_substr(%v, '[^,]+', 1, level) is not null)", "1,2,3,4", "1,2,3,4");
@endcode
@subsection ora_partitioning_select Partition Support in Selects
It's possible to select from a particular partition of a table with %OracleSqlUtil;
@ref OracleSqlUtil::OracleTable::OracleSelectOptions "OracleSelectOptions" defines the \c "partition" key which can be added to a
@ref select_option_hash "select option hash " to specify the partition to select from as in the following example:
@code
my *list $rows = $table.selectRows(("created": op_gt(2012-05-01), "partition": "p1"));
@endcode
Which generates an SQL command like the following:
@code
my *list $rows = $ds.vselectRows("select * from schema.table partition(p1) where created > %v", (2012-05-01));
@endcode
@subsection ora_partitioning_join Partition Support in Joins
It's possible to perform a join on a particular partition of a table with %OracleSqlUtil; the join option \c "partition" is
supported to specify the partition to join on as in the following example:
@code
my *list $rows = $table.selectRows(("join": join_inner($table2, "t2", ("id": "altid"), NOTHING, ("partition": "p2"))));
@endcode
Which generates an SQL command like the following:
@code
my *list $rows = $ds.vselectRows("select * from schema.table inner join schema.table2 partition(p2) t2 on (schema.table.id = t2.altid)");
@endcode
@section ora_schema_management Schema Management on Oracle
Note that when getting an object description from an Oracle database, if the object cannot be found in the connection schema, then
if a synonym of the same type exists and the target object is accessible, then the target object is read automatically and the owning
schema name is also set to the actual owner of the object.
@subsection ora_type_mapping Type Mapping
Column types are mapped from %Qore types as follows:
<b>Oracle Column Type Mappings</b>
@htmlonly <style><!-- td.qore { background-color: #5b9409; color: white; } --></style> @endhtmlonly
<table>
<tr>
<td class="qore"><b>Generic Type Name</b></td>
<td class="qore"><b>Oracle Type Used</b></td>
</tr>
<tr>
<td>\c float</td>
<td>\c number</td>
</tr>
<tr>
<td>\c integer</td>
<td>\c number</td>
</tr>
<tr>
<td>\c number</td>
<td>\c number</td>
</tr>
<tr>
<td>\c string</td>
<td>\c varchar2</td>
</tr>
<tr>
<td>\c date</td>
<td>\c timestamp(6)</td>
</tr>
<tr>
<td>\c binary</td>
<td>\c blob</td>
</tr>
<tr>
<td>@ref SqlUtil::BLOB</td>
<td>\c blob</td>
</tr>
<tr>
<td>@ref SqlUtil::CHAR</td>
<td>\c char</td>
</tr>
<tr>
<td>@ref SqlUtil::CLOB</td>
<td>\c clob</td>
</tr>
<tr>
<td>@ref SqlUtil::NUMERIC</td>
<td>\c number</td>
</tr>
<tr>
<td>@ref SqlUtil::VARCHAR</td>
<td>\c varchar2</td>
</tr>
</table>
To use other types, use the \c "native_type" @ref SqlUtil::AbstractTable::ColumnDescOptions "column description option" with the
native Oracle type name instead (under the \c "driver" and \c "oracle" keys for schemas supporting multiple databases).
@subsection ora_other_objects Additional Object Types Supported
The following additional schema objects can be managed with %OracleSqlUtil:
- @ref ora_materialized_views "materialized views"
- @ref ora_packages "packages"
- @ref ora_types "types"
@subsection ora_materialized_views Materialized Views
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.
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
following keys:
- \c "logging": (@ref bool_type "bool") if the materialized view should be logged
- \c "use_index": (@ref bool_type "bool") if the materialized view should be indexed
- \c "src": (@ref bool_type "bool") the source of the materialized view
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:
@code
my hash $schema = (
"driver": (
"oracle": (
"materialized_views": (
"example_mv": (
"logging": False,
"use_index": False,
"src": "select type, count(1) total_count from table group by type",
),
),
),
),
);
@endcode
@subsection ora_packages Packages
The @ref schema_desc_hash takes an optional key, \c "packages" that allows packages in Oracle schemas to be managed along with other objects.
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
following key:
- \c "src": (@ref bool_type "bool") the source of the package
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:
@code
my hash $schema = (
"driver": (
"oracle": (
"packages": (
"example_pkg": (
"src": "types as
type cursorType is ref cursor;
MYSTATCOMPLETE constant order_status.orderstatus%type := 'C';
MYSTATERROR constant order_status.orderstatus%type := 'E';
",
),
),
),
),
);
@endcode
@subsection ora_types Types
The @ref schema_desc_hash takes an optional key, \c "types" that allows types in Oracle schemas to be managed along with other objects.
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.
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:
@code
my hash $schema = (
"driver": (
"oracle": (
"types": (
"num_array": "table of number",
"str_array": "table of varchar2(240)",
),
),
),
);
@endcode
@see OracleSqlUtil::OracleDatabase::OracleSchemaDescriptionOptions for a list of Oracle-specific schema description hash keys.
@section ora_relnotes Release Notes
@subsection v10 OracleSqlUtil v1.0
- initial release
*/
namespace OracleSqlUtil {
OracleTable get_table(AbstractDatasource nds, string nname, *hash opts);
OracleDatabase get_database(AbstractDatasource nds, *hash opts);
class OracleColumn : public SqlUtil::AbstractColumn {
public:
public :
bool char_used;
int byte_size;
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, bool is_char = False, bool cu = False, int bs);
string getNativeTypeString();
list getCreateSql(AbstractTable t);
list getModifySqlImpl(AbstractTable t, AbstractColumn col, *hash opt);
string getRenameSql(AbstractTable t, string new_name);
bool equalImpl(AbstractColumn c);
};
class OracleNumberColumn : public OracleColumn,public SqlUtil::NumericColumnInfo {
public:
constructor(string n, string nt, *string qt, int sz, bool nul, *string dv, *string cm, int bs, int n_scale = 0);
string getNativeTypeString();
};
class OracleIndex : public SqlUtil::AbstractIndex {
public:
public :
string native_type;
*string tablespace;
public:
constructor(string n, bool u, hash c, string nt, *string t);
string getCreateSql(string table_name, *hash opt);
bool equalImpl(AbstractIndex ix);
string getRenameSql(string table_name, string new_name);
};
class OracleForeignConstraint : public SqlUtil::AbstractForeignConstraint {
public:
public :
bool enabled;
public:
constructor(string n, Columns c, ForeignConstraintTarget t, bool e);
string getCreateSql(string table_name, *hash opt);
softlist getRenameSql(string table_name, string new_name);
string getDisableSql(string table_name);
string getEnableSql(string table_name, *hash opt);
};
class OracleCheckConstraint : public SqlUtil::AbstractCheckConstraint {
public:
public :
bool enabled;
public:
constructor(string n, string n_src, bool e = True);
string getCreateSql(string table_name, *hash opt);
softlist getRenameSql(string table_name, string new_name);
string getDisableSql(string table_name);
string getEnableSql(string table_name, *hash opt);
};
class OracleUniqueConstraint : public SqlUtil::AbstractUniqueConstraint {
public:
private :
bool enabled;
*string tablespace;
public:
constructor(string n, hash n_cols, bool e = True, *string ts);
OracleColumn memberGate(string k);
bool setIndexBase(string ix);
clearIndex();
string getCreateSql(string table_name, *hash opts);
softlist getRenameSql(string table_name, string new_name);
string getDisableSql(string table_name);
string getEnableSql(string table_name, *hash opt);
};
class OraclePrimaryKey : public SqlUtil::AbstractPrimaryKey {
public:
private :
*string tablespace;
public:
constructor();
constructor(string n, *hash c, *string ts);
OracleColumn memberGate(string k);
bool setIndexBase(string ix);
clearIndex();
string getCreateSql(string table_name, *hash opts);
softlist getRenameSql(string table_name, string new_name);
string getDropSql(string table_name);
string getDisableSql(string table_name);
string getEnableSql(string table_name, *hash opt);
};
class OracleSequence : public SqlUtil::AbstractSequence {
public:
constructor(string n_name, number n_start = 1, number n_increment = 1, *softnumber n_end);
string getCreateSql(*hash opt);
string getRenameSql(string new_name);
};
class OracleView : public SqlUtil::AbstractView {
public:
public :
*string type_text;
*string oid_text;
*string view_type_owner;
*string view_type;
*string superview_name;
bool container_data;
public:
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)
;
string getCreateSql(*hash opt);
softlist getRenameSql(string new_name);
};
class OracleTrigger : public SqlUtil::AbstractTrigger {
public:
public :
bool enabled;
public:
constructor(string n, string n_src, bool en = True);
softlist getCreateSql(string table_name, *hash opt);
bool equalImpl(AbstractFunctionBase t);
softlist getRenameSql(string table_name, string new_name);
softlist getDropSql(string table_name);
};
class OracleCodeBase : public SqlUtil::AbstractFunction {
public:
constructor(string n, string n_type, string n_src);
softlist getCreateSql(*hash opt);
bool equalImpl(AbstractFunctionBase t);
list getRenameSql(string new_name);
};
class OracleType : public OracleCodeBase {
public:
constructor(string n_name, string n_src);
};
class OracleFunction : public OracleCodeBase {
public:
constructor(string n, string n_src);
};
class OracleProcedure : public OracleCodeBase {
public:
constructor(string n, string n_src);
};
class OraclePackage : public OracleCodeBase {
public:
private :
*string body_src;
public:
constructor(string n, string n_src, *string n_body_src);
list getCreateSql(*hash opt);
bool equalImpl(AbstractFunctionBase t);
};
class OracleMaterializedView : public OracleCodeBase {
public:
public :
bool logging;
bool use_index;
*string tablespace;
public:
constructor(string n, string n_src, bool n_logging = True, bool n_use_index = True, *string n_tablespace);
softlist getCreateSql(*hash opt);
bool equalImpl(AbstractFunctionBase t);
};
class OracleDatabase : public SqlUtil::AbstractDatabase {
public:
public :
const OracleCreationOptions = AbstractDatabase::CreationOptions + (
"compute_statistics": Type::Boolean,
);
const OracleAlignSchemaOptions = AbstractDatabase::CreationOptions
+ OracleCreationOptions
+ OracleTable::OracleAlignTableOptions
;
const OracleSchemaDescriptionOptions = AbstractDatabase::SchemaDescriptionOptions + (
"types": Type::Hash,
"type_map": Type::Hash,
"packages": Type::Hash,
"package_map": Type::Hash,
"materialized_views": Type::Hash,
"materialized_view_map": Type::Hash,
//"synonyms": Type::Hash,
//"synonym_map": Type::Hash,
);
const OraclePackageDescriptionOptions = (
"src": Type::String,
"body": Type::String,
);
const OracleMaterializedViewDescriptionOptions = (
"logging": Type::Boolean,
"use_index": Type::Boolean,
"tablespace": Type::String,
"src": Type::String,
);
public:
constructor(AbstractDatasource nds, *hash opts);
private list featuresImpl();
private OracleSequence makeSequenceImpl(string name, number start = 1, number increment = 1, *softnumber end, *hash opts);
private getSchemaName(reference name, reference schema);
private *AbstractSequence getSequenceImpl(string name);
private *AbstractView getViewImpl(string name);
private OracleFunction makeFunctionImpl(string name, string src, *hash opts);
private OracleProcedure makeProcedureImpl(string name, string src, *hash opts);
OraclePackage makePackage(string name, string src, string body, *hash opts);
OraclePackage makePackageFromDescription(string name, hash ph, *hash opts);
OracleType makeType(string name, string src, *hash opts);
OracleMaterializedView makeMaterializedView(string name, string src, bool logging = True, bool use_index = True, *string tablespace, *hash opts);
OracleMaterializedView makeMaterializedViewFromDescription(string name, hash mvh, *hash opts);
private list getDropSchemaSqlImpl(hash schema_hash, *hash opt);
private list getAlignSqlImpl(hash schema_hash, *hash opt);
private *OracleFunction getFunctionImpl(string name);
private *OracleProcedure getProcedureImpl(string name);
*OraclePackage getPackage(string name);
*OracleType getType(string name);
*OracleMaterializedView getMaterializedView(string name);
private *string getSource(string type, string name);
private checkSource(string type, string name, reference src);
list listSynonyms();
ListIterator synonymIterator();
list listTypes();
ListIterator typeIterator();
list listPackages();
ListIterator packageIterator();
list listMaterializedViews();
ListIterator materializedViewIterator();
private list listTablesImpl();
private list listFunctionsImpl();
private list listProceduresImpl();
private list listSequencesImpl();
private list listViewsImpl();
private list getListIntern(string type);
private list getListIntern(list l);
private string getCreateSqlImpl(list l);
static string getCreateSql(list l);
private hash getCreationOptions();
private hash getAlignSchemaOptions();
private hash getSchemaDescriptionOptions();
private softint getNextSequenceValueImpl(string name);
private bool supportsSequencesImpl();
private bool supportsTypesImpl();
private bool supportsPackagesImpl();
};
class OracleTable : public SqlUtil::AbstractTable {
public:
public :
const OraTypeMap = (
"number": ("qore": Type::Number, "size": SZ_NUM, "size_range": (1, 38), "scale_range": (-84, 127)),
"varchar2": ("qore": Type::String, "size": SZ_MAND, "size_range": (1, 4000), "is_char": True),
"char": ("qore": Type::String, "size": SZ_MAND, "size_range": (1, 4000), "is_char": True),
"date": ("qore": Type::Date,),
"timestamp": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
"timestamp with time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
"timestamp with local time zone": ("qore": Type::Date, "size": SZ_OPT, "size_range": (0, 9)),
"timestamp(0)": ("qore": Type::Date,),
"timestamp(1)": ("qore": Type::Date,),
"timestamp(2)": ("qore": Type::Date,),
"timestamp(3)": ("qore": Type::Date,),
"timestamp(4)": ("qore": Type::Date,),
"timestamp(5)": ("qore": Type::Date,),
"timestamp(6)": ("qore": Type::Date,),
"timestamp(7)": ("qore": Type::Date,),
"timestamp(8)": ("qore": Type::Date,),
"timestamp(9)": ("qore": Type::Date,),
"timestamp(0) with time zone": ("qore": Type::Date,),
"timestamp(1) with time zone": ("qore": Type::Date,),
"timestamp(2) with time zone": ("qore": Type::Date,),
"timestamp(3) with time zone": ("qore": Type::Date,),
"timestamp(4) with time zone": ("qore": Type::Date,),
"timestamp(5) with time zone": ("qore": Type::Date,),
"timestamp(6) with time zone": ("qore": Type::Date,),
"timestamp(7) with time zone": ("qore": Type::Date,),
"timestamp(8) with time zone": ("qore": Type::Date,),
"timestamp(9) with time zone": ("qore": Type::Date,),
"timestamp(0) with local time zone": ("qore": Type::Date,),
"timestamp(1) with local time zone": ("qore": Type::Date,),
"timestamp(2) with local time zone": ("qore": Type::Date,),
"timestamp(3) with local time zone": ("qore": Type::Date,),
"timestamp(4) with local time zone": ("qore": Type::Date,),
"timestamp(5) with local time zone": ("qore": Type::Date,),
"timestamp(6) with local time zone": ("qore": Type::Date,),
"timestamp(7) with local time zone": ("qore": Type::Date,),
"timestamp(8) with local time zone": ("qore": Type::Date,),
"timestamp(9) with local time zone": ("qore": Type::Date,),
"interval year(0) to month": ("qore": Type::Date,),
"interval year(1) to month": ("qore": Type::Date,),
"interval year(2) to month": ("qore": Type::Date,),
"interval year(3) to month": ("qore": Type::Date,),
"interval year(4) to month": ("qore": Type::Date,),
"interval year(5) to month": ("qore": Type::Date,),
"interval year(6) to month": ("qore": Type::Date,),
"interval year(7) to month": ("qore": Type::Date,),
"interval year(8) to month": ("qore": Type::Date,),
"interval year(9) to month": ("qore": Type::Date,),
"interval day(0) to second(0)": ("qore": Type::Date,),
"interval day(0) to second(1)": ("qore": Type::Date,),
"interval day(0) to second(2)": ("qore": Type::Date,),
"interval day(0) to second(3)": ("qore": Type::Date,),
"interval day(0) to second(4)": ("qore": Type::Date,),
"interval day(0) to second(5)": ("qore": Type::Date,),
"interval day(0) to second(6)": ("qore": Type::Date,),
"interval day(0) to second(7)": ("qore": Type::Date,),
"interval day(0) to second(8)": ("qore": Type::Date,),
"interval day(0) to second(9)": ("qore": Type::Date,),
"interval day(1) to second(0)": ("qore": Type::Date,),
"interval day(1) to second(1)": ("qore": Type::Date,),
"interval day(1) to second(2)": ("qore": Type::Date,),
"interval day(1) to second(3)": ("qore": Type::Date,),
"interval day(1) to second(4)": ("qore": Type::Date,),
"interval day(1) to second(5)": ("qore": Type::Date,),
"interval day(1) to second(6)": ("qore": Type::Date,),
"interval day(1) to second(7)": ("qore": Type::Date,),
"interval day(1) to second(8)": ("qore": Type::Date,),
"interval day(1) to second(9)": ("qore": Type::Date,),
"interval day(2) to second(0)": ("qore": Type::Date,),
"interval day(2) to second(1)": ("qore": Type::Date,),
"interval day(2) to second(2)": ("qore": Type::Date,),
"interval day(2) to second(3)": ("qore": Type::Date,),
"interval day(2) to second(4)": ("qore": Type::Date,),
"interval day(2) to second(5)": ("qore": Type::Date,),
"interval day(2) to second(6)": ("qore": Type::Date,),
"interval day(2) to second(7)": ("qore": Type::Date,),
"interval day(2) to second(8)": ("qore": Type::Date,),
"interval day(2) to second(9)": ("qore": Type::Date,),
"clob": ("qore": Type::String,),
"blob": ("qore": Type::Binary,),
"long": ("qore": Type::Binary,),
"raw": ("qore": Type::Binary, "size": SZ_MAND, "size_range": (1, 2000)),
"bfile": ("qore": Type::Binary,),
"binary_float": ("qore": Type::Float,),
"binary_double": ("qore": Type::Float,),
"rowid": ("qore": Type::String,),
"urowid": ("qore": Type::String, "size": SZ_OPT, "size_range": (1, 4000)),
);
const QoreTypeMap = (
"integer": "number",
"float": "number",
"number": "number",
"string": "varchar2",
"date": "timestamp(6)",
"binary": "blob",
SqlUtil::CHAR: "char",
SqlUtil::CLOB: "clob",
SqlUtil::BLOB: "blob",
);
const OraColumnOpts = (
"character_semantics": Type::Boolean,
);
const OraColumnOptions = AbstractTable::ColumnOptions + OraColumnOpts;
const OraColumnDescOptions = AbstractTable::ColumnDescOptions + OraColumnOpts;
const OracleIndexOptions = AbstractTable::IndexOptions + (
"compute_statistics": Type::Boolean,
);
const OracleConstraintOptions = OracleIndexOptions + (
"index": Type::String,
);
const OracleTableCreationOptions = AbstractTable::TableCreationOptions
+ OracleConstraintOptions
+ OraColumnOptions
;
const OracleAlignTableOptions = AbstractTable::AlignTableOptions + OracleTableCreationOptions;
const OracleSelectOptions = AbstractTable::SelectOptions + (
"partition": Type::String,
);
const OracleOpMap = DefaultOpMap + (
OP_IN: (
"code": string (object t, string cn, any arg, reference args) {
*string argstr = (foldl $1 + "," + $2, (map $1.toString(), arg));
// in this case this part of the expression will fail
if (!argstr)
return "1 != 1";
args += argstr;
args += argstr;
return cn + " in (select regexp_substr(%v,'[^,]+', 1, level) from dual connect by regexp_substr(%v, '[^,]+', 1, level) is not null)";
},
),
);
const OracleCopMap = DefaultCopMap + (
COP_OVER: (
"argcolumn": True,
"argoptional": True,
"code": string (*string cve, *string arg) {
string sql = cve + " over (";
if (arg)
sql += sprintf("partition by %s", arg);
sql += ")";
return sql;
},
),
COP_YEAR: (
"code": string (string arg1, any arg) {
return sprintf("to_char(%s, 'YYYY')", arg1);
}
),
COP_YEAR_MONTH: (
"code": string (string arg1, any arg) {
return sprintf("to_char(%s, 'YYYY-MM')", arg1);
}
),
COP_YEAR_DAY: (
"code": string (string arg1, any arg) {
return sprintf("to_char(%s, 'YYYY-MM-DD')", arg1);
}
),
COP_YEAR_HOUR: (
"code": string (string arg1, any arg) {
return sprintf("to_char(%s, 'YYYY-MM-DD HH24')", arg1);
}
),
);
public:
private :
// schema name
string schema;
// tablespace name
*string tablespace;
// is the table read only?
bool readonly;
// table comment
*string comment;
// dblink
*string dblink;
// Oracle server major version
int ora_major;
public:
constructor(AbstractDatasource nds, string nname, *hash opts);
private bool checkExistenceImpl();
private setTableInfoIntern();
string getSqlName();
private hash setSchemaTable();
private setDblinkSchema();
private hash setTable();
private string getUserSchema();
private string getDBString();
string getSchemaName();
*string getTablespaceName();
*string getComment();
bool readOnly();
private hash getColumnOptions();
private hash getColumnDescOptions();
private hash getSelectOptions();
private getSelectWhereSqlUnlocked(reference sql, reference args, *hash qh, *hash jch, bool join = False, *hash ch);
private doSelectOrderByWithOffsetSqlUnlockedImpl(reference sql, reference args, *hash qh, *hash jch, *hash ch);
private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh);
private Columns describeImpl();
private OraclePrimaryKey getPrimaryKeyImpl();
private Indexes getIndexesImpl();
private ForeignConstraints getForeignConstraintsImpl(*hash opts);
private Constraints getConstraintsImpl();
private string getSelectSqlName(*hash qh);
private Triggers getTriggersImpl();
string getCreateTableSqlImpl(*hash opt);
private *list getCreateMiscSqlImpl(*hash opt, bool cache);
private string getCreateSqlImpl(list l);
private string getRenameSqlImpl(string new_name);
private AbstractColumn addColumnImpl(string cname, hash opt, bool nullable = True);
private AbstractPrimaryKey addPrimaryKeyImpl(string cname, hash ch, *hash opt);
private AbstractIndex addIndexImpl(string iname, bool enabled, hash ch, *hash opt);
private AbstractForeignConstraint addForeignConstraintImpl(string cname, hash ch, string table, hash tch, *hash opt);
private AbstractCheckConstraint addCheckConstraintImpl(string cname, string src, *hash opt);
private AbstractUniqueConstraint addUniqueConstraintImpl(string cname, hash ch, *hash opt);
private AbstractTrigger addTriggerImpl(string tname, string src, *hash opt);
private bool tryInsertImpl(string sql, hash row);
private *list getAlignSqlImpl(AbstractTable t, *hash opt);
private hash getQoreTypeMapImpl();
private hash getTypeMapImpl();
private hash getIndexOptions();
private hash getConstraintOptions();
private hash getTableCreationOptions();
private hash getAlignTableOptions();
private hash getWhereOperatorMap();
private hash getColumnOperatorMap();
private *string getSqlValueImpl(any v);
private bool emptyImpl();
private setupTableImpl(hash desc, *hash opt);
private bool constraintsLinkedToIndexesImpl();
private bool uniqueIndexCreatesConstraintImpl();
private bool supportsTablespacesImpl();
private copyImpl(AbstractTable old);
};
};
OracleSqlUtil::OracleUniqueConstraint
represents an Oracle unique constraint
Definition: OracleSqlUtil.qm.dox.h:447
OracleSqlUtil::OracleTable::getSelectOptions
private hash getSelectOptions()
override in subclasses to return driver-specific options
Date
const Date
OracleSqlUtil::OracleMaterializedView
represents an Oracle materialized view
Definition: OracleSqlUtil.qm.dox.h:735
date
date date(date dt)
Hash
const Hash
OracleSqlUtil::OracleDatabase::OracleCreationOptions
const OracleCreationOptions
oracle-specific generic creation options
Definition: OracleSqlUtil.qm.dox.h:772
OracleSqlUtil::OracleDatabase::listSynonyms
list listSynonyms()
returns a list of string synonym names in the database
OracleSqlUtil::OracleDatabase::getAlignSchemaOptions
private hash getAlignSchemaOptions()
returns driver-specific options to the base abstract class
String
const String
sprintf
string sprintf(string fmt,...)
OP_IN
const OP_IN
SqlUtil::AbstractTable
OracleSqlUtil::OracleTrigger::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
DefaultCopMap
const DefaultCopMap
OracleSqlUtil::OracleDatabase::packageIterator
ListIterator packageIterator()
returns an iterator listing the string package names in the database
SqlUtil::VARCHAR
const VARCHAR
OracleSqlUtil::OracleIndex::tablespace
*string tablespace
the tablespace name of the index (if supported)
Definition: OracleSqlUtil.qm.dox.h:369
OracleSqlUtil::OracleCheckConstraint::getDisableSql
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database ...
OracleSqlUtil::OraclePrimaryKey::getDropSql
string getDropSql(string table_name)
returns a string that can be used to drop the constraint from the database
OracleSqlUtil::OracleMaterializedView::logging
bool logging
Flag if is loggign mode used.
Definition: OracleSqlUtil.qm.dox.h:740
OracleSqlUtil::OracleView::view_type_owner
*string view_type_owner
Owner of the type of the view if the view is a typed view.
Definition: OracleSqlUtil.qm.dox.h:594
OracleSqlUtil::OracleTable
represents an Oracle table
Definition: OracleSqlUtil.qm.dox.h:977
SqlUtil::AbstractTable::cache
cache(*hash opts)
OracleSqlUtil::OracleDatabase::supportsSequencesImpl
private bool supportsSequencesImpl()
returns True if the database supports sequences
OracleSqlUtil::OraclePrimaryKey::getDisableSql
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database ...
OracleSqlUtil::OracleDatabase::synonymIterator
ListIterator synonymIterator()
returns an iterator listing the string synonym names in the database
SqlUtil::AbstractIndex
OracleSqlUtil::OraclePackage::getCreateSql
list getCreateSql(*hash opt)
returns a string that can be used to create the package in the database
OracleSqlUtil::OracleMaterializedView::tablespace
*string tablespace
Name of the potential tablespace.
Definition: OracleSqlUtil.qm.dox.h:744
COP_OVER
const COP_OVER
OracleSqlUtil::OracleCodeBase::constructor
constructor(string n, string n_type, string n_src)
creates the object from the arguments passed
OracleSqlUtil::OracleDatabase::supportsPackagesImpl
private bool supportsPackagesImpl()
returns True if the database supports packages
OracleSqlUtil::OracleDatabase::OracleMaterializedViewDescriptionOptions
const OracleMaterializedViewDescriptionOptions
oracle-specific materialized view description options
Definition: OracleSqlUtil.qm.dox.h:812
OracleSqlUtil::OracleDatabase::materializedViewIterator
ListIterator materializedViewIterator()
returns an iterator listing the string materialized view names in the database
OracleSqlUtil::OracleDatabase::supportsTypesImpl
private bool supportsTypesImpl()
returns True if the database supports named types
OracleSqlUtil::OracleUniqueConstraint::getDisableSql
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database ...
OracleSqlUtil::OracleCodeBase::getRenameSql
list getRenameSql(string new_name)
returns a string that can be used to rename the object in the database
OracleSqlUtil::OracleSequence::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the sequence in the database
OracleSqlUtil::OracleView::superview_name
*string superview_name
Name of the superview.
Definition: OracleSqlUtil.qm.dox.h:598
OracleSqlUtil::OracleTrigger::enabled
bool enabled
True if the trigger is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:627
SqlUtil::NumericColumnInfo
True
const True
SZ_MAND
const SZ_MAND
SqlUtil::CHAR
const CHAR
OracleSqlUtil::OracleTable::OracleIndexOptions
const OracleIndexOptions
Oracle-specific index options.
Definition: OracleSqlUtil.qm.dox.h:1104
OracleSqlUtil::OracleDatabase::getCreationOptions
private hash getCreationOptions()
returns driver-specific options to the base abstract class
SqlUtil::AbstractSequence
OracleSqlUtil::OracleForeignConstraint::enabled
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:396
OracleSqlUtil::OracleCheckConstraint::enabled
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:424
OracleSqlUtil::OracleView::constructor
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
OracleSqlUtil::OracleProcedure
represents an Oracle procedure
Definition: OracleSqlUtil.qm.dox.h:696
number
number number(softnumber n)
COP_YEAR_HOUR
const COP_YEAR_HOUR
OracleSqlUtil::OraclePrimaryKey::memberGate
OracleColumn memberGate(string k)
returns the OracleColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
OracleSqlUtil::OracleTable::OracleOpMap
const OracleOpMap
where operator specializations for Oracle
Definition: OracleSqlUtil.qm.dox.h:1134
binary
binary binary()
OracleSqlUtil::OracleTable::supportsTablespacesImpl
private bool supportsTablespacesImpl()
returns True if the database support tablespaces
OracleSqlUtil::OracleFunction::constructor
constructor(string n, string n_src)
creates the object from the arguments passed
OracleSqlUtil::OracleTable::OracleTableCreationOptions
const OracleTableCreationOptions
Oracle table creation options.
Definition: OracleSqlUtil.qm.dox.h:1117
OracleSqlUtil::OracleIndex::equalImpl
bool equalImpl(AbstractIndex ix)
returns True if the argument is equal to the current index, False if not
OracleSqlUtil::OracleDatabase::listTypes
list listTypes()
returns a list of string type names in the database
SqlUtil::AbstractForeignConstraint
False
const False
OracleSqlUtil::OracleUniqueConstraint::tablespace
*string tablespace
any tablespace for the unique key index
Definition: OracleSqlUtil.qm.dox.h:455
SqlUtil::AbstractSqlUtilBase::l
Mutex l()
OracleSqlUtil::OracleUniqueConstraint::enabled
bool enabled
True if the constraint is enabled, False if not
Definition: OracleSqlUtil.qm.dox.h:452
OracleSqlUtil::OracleView
represents an Oracle view
Definition: OracleSqlUtil.qm.dox.h:584
SqlUtil::AbstractCheckConstraint
OracleSqlUtil::OraclePackage::constructor
constructor(string n, string n_src, *string n_body_src)
creates the object from the arguments passed
OracleSqlUtil::OracleDatabase::listMaterializedViews
list listMaterializedViews()
returns a list of string materialized view names in the database
list
list list(...)
Float
const Float
OracleSqlUtil::OracleDatabase::getSchemaDescriptionOptions
private hash getSchemaDescriptionOptions()
returns driver-specific options to the base abstract class
Boolean
const Boolean
OracleSqlUtil::OracleForeignConstraint::getEnableSql
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
OracleSqlUtil::OracleSequence::constructor
constructor(string n_name, number n_start=1, number n_increment=1, *softnumber n_end)
creates the object from the arguments
SZ_NUM
const SZ_NUM
SqlUtil::AbstractColumn::getCreateSql
string getCreateSql()
Binary
const Binary
OracleSqlUtil::OracleTrigger::getRenameSql
softlist getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the trigger in the database
OracleSqlUtil::OracleView::getRenameSql
softlist getRenameSql(string new_name)
returns a string that can be used to rename the view in the database
OracleSqlUtil::OracleDatabase::typeIterator
ListIterator typeIterator()
returns an iterator listing the string type names in the database
OracleSqlUtil::OracleView::oid_text
*string oid_text
WITH OID clause of the typed view.
Definition: OracleSqlUtil.qm.dox.h:592
OracleSqlUtil::OracleIndex::getRenameSql
string getRenameSql(string table_name, string new_name)
returns a string that can be used to rename the index in the database
exists
bool exists(...)
OracleSqlUtil::OracleView::getCreateSql
string getCreateSql(*hash opt)
returns a string that can be used to create the view in the database
OracleSqlUtil::OracleUniqueConstraint::getEnableSql
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
OracleSqlUtil::OracleTable::OraColumnDescOptions
const OraColumnDescOptions
Oracle-specific column options.
Definition: OracleSqlUtil.qm.dox.h:1098
OracleSqlUtil::OracleTable::constraintsLinkedToIndexesImpl
private bool constraintsLinkedToIndexesImpl()
returns True if the database links constraints to indexes (ie dropping the constraint drops the index...
OracleSqlUtil::OracleMaterializedView::use_index
bool use_index
Flag if is index used.
Definition: OracleSqlUtil.qm.dox.h:742
COP_YEAR_MONTH
const COP_YEAR_MONTH
OracleSqlUtil::OracleTable::getWhereOperatorMap
private hash getWhereOperatorMap()
returns the &quot;where&quot; operator map for this object
OracleSqlUtil::OracleCodeBase::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
OracleSqlUtil::OracleIndex::constructor
constructor(string n, bool u, hash c, string nt, *string t)
creates the object from the arguments
SqlUtil::BLOB
const BLOB
OracleSqlUtil::OracleDatabase
the Oracle specialization for SqlUtil::AbstractDatabase
Definition: OracleSqlUtil.qm.dox.h:767
type
string type(any arg)
OracleSqlUtil::OracleColumn::byte_size
int byte_size
byte size of the column
Definition: OracleSqlUtil.qm.dox.h:294
SqlUtil::CLOB
const CLOB
OracleSqlUtil::OracleColumn::getNativeTypeString
string getNativeTypeString()
returns the string describing the native type that can be used in SQL (for example to add the colunn ...
OracleSqlUtil::OracleColumn::equalImpl
bool equalImpl(AbstractColumn c)
returns True if the argument is equal to the current object, False if not
OracleSqlUtil::OracleDatabase::OraclePackageDescriptionOptions
const OraclePackageDescriptionOptions
oracle-specific package description options
Definition: OracleSqlUtil.qm.dox.h:806
NOTHING
const NOTHING
OracleSqlUtil::OracleSequence::getRenameSql
string getRenameSql(string new_name)
returns a string that can be used to rename the sequence in the database
OracleSqlUtil::OracleTable::OraTypeMap
const OraTypeMap
maps oracle type names to type descriptions
Definition: OracleSqlUtil.qm.dox.h:982
string
string string(softstring str)
OracleSqlUtil::OracleDatabase::OracleAlignSchemaOptions
const OracleAlignSchemaOptions
oracle-specific schema description / alignment options
Definition: OracleSqlUtil.qm.dox.h:777
SqlUtil::AbstractFunction
OracleSqlUtil::OracleColumn::getRenameSql
string getRenameSql(AbstractTable t, string new_name)
returns a string that can be used to rename the column
OracleSqlUtil::OraclePackage::equalImpl
bool equalImpl(AbstractFunctionBase t)
returns True if the argument is equal to the current object, False if not
OracleSqlUtil::OracleTable::OracleConstraintOptions
const OracleConstraintOptions
Oracle-specific constraint options.
Definition: OracleSqlUtil.qm.dox.h:1112
OracleSqlUtil::OracleUniqueConstraint::memberGate
OracleColumn memberGate(string k)
returns the OracleColumn value of the given key if it exists, otherwise throws a KEY-ERROR exception ...
OracleSqlUtil::OracleMaterializedView::getCreateSql
softlist getCreateSql(*hash opt)
returns a string that can be used to create the object in the database
OracleSqlUtil::OracleTable::getComment
*string getComment()
returns any table comment or NOTHING if none is known
SqlUtil::AbstractView
OracleSqlUtil::OracleTable::getSchemaName
string getSchemaName()
returns the schema name
OracleSqlUtil::OracleCheckConstraint
represents an Oracle check constraint
Definition: OracleSqlUtil.qm.dox.h:419
OracleSqlUtil::OracleTable::getSqlName
string getSqlName()
returns the schema and table naem in dot notation
OracleSqlUtil::OracleCheckConstraint::getEnableSql
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
OracleSqlUtil::OracleMaterializedView::constructor
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
OracleSqlUtil::OracleNumberColumn
represents an Oracle number column
Definition: OracleSqlUtil.qm.dox.h:350
OracleSqlUtil::OracleUniqueConstraint::clearIndex
clearIndex()
clears any index base for the constraint
OracleSqlUtil::OraclePackage
represents an Oracle package
Definition: OracleSqlUtil.qm.dox.h:708
COP_YEAR
const COP_YEAR
OracleSqlUtil::OracleColumn::getModifySqlImpl
list 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; if the col...
OracleSqlUtil::OracleColumn
represents an Oracle column
Definition: OracleSqlUtil.qm.dox.h:287
OracleSqlUtil::OracleView::type_text
*string type_text
Type clause of the typed view.
Definition: OracleSqlUtil.qm.dox.h:590
OracleSqlUtil::get_database
OracleDatabase get_database(AbstractDatasource nds, *hash opts)
returns an OracleDatabase object corresponding to the arguments
OracleSqlUtil::OracleCodeBase::getCreateSql
softlist getCreateSql(*hash opt)
returns a string that can be used to create the object in the database
OracleSqlUtil::OracleTable::OracleCopMap
const OracleCopMap
column operator specializations for Oracle
Definition: OracleSqlUtil.qm.dox.h:1152
OracleSqlUtil::OracleTable::getColumnOperatorMap
private hash getColumnOperatorMap()
returns the column operator map for this object
SqlUtil::AbstractTrigger
SqlUtil::AbstractColumn
OracleSqlUtil::OracleTable::OracleSelectOptions
const OracleSelectOptions
Oracle select options.
Definition: OracleSqlUtil.qm.dox.h:1129
OracleSqlUtil::OracleTable::QoreTypeMap
const QoreTypeMap
maps qore type names to an oracle type
Definition: OracleSqlUtil.qm.dox.h:1072
join_inner
hash join_inner(AbstractTable table, *string alias, *hash jcols, *hash cond, *hash opt)
OracleSqlUtil::OraclePackage::body_src
*string body_src
package body source
Definition: OracleSqlUtil.qm.dox.h:713
OracleSqlUtil::OracleTable::getSqlValueImpl
private *string getSqlValueImpl(any v)
returns a string for use in SQL queries representing the DB-specific value of the argument; returns N...
OracleSqlUtil::OracleProcedure::constructor
constructor(string n, string n_src)
creates the object from the arguments passed
COP_YEAR_DAY
const COP_YEAR_DAY
OracleSqlUtil::OracleTable::uniqueIndexCreatesConstraintImpl
private bool uniqueIndexCreatesConstraintImpl()
returns True if the database automatically creates a unique constraint when a unique index is created...
OracleSqlUtil::OraclePrimaryKey::tablespace
*string tablespace
any tablespace for the primary key index
Definition: OracleSqlUtil.qm.dox.h:509
OracleSqlUtil::OracleView::view_type
*string view_type
Type of the view if the view is a typed view.
Definition: OracleSqlUtil.qm.dox.h:596
OracleSqlUtil::OraclePrimaryKey::getEnableSql
string getEnableSql(string table_name, *hash opt)
returns a string that can be used to enable the constraint in the database
SqlUtil::AbstractTable::ColumnDescOptions
const ColumnDescOptions
OracleSqlUtil::OracleTable::copyImpl
private copyImpl(AbstractTable old)
db-specific copy actions
OracleSqlUtil::OracleDatabase::listPackages
list listPackages()
returns a list of string package names in the database
Object
const Object
OracleSqlUtil::OracleSequence
represents an Oracle sequence
Definition: OracleSqlUtil.qm.dox.h:567
OracleSqlUtil::OracleTrigger
represents an Oracle trigger
Definition: OracleSqlUtil.qm.dox.h:622
OracleSqlUtil::OracleTrigger::getDropSql
softlist getDropSql(string table_name)
returns a string that can be used to drop the trigger from the database
OracleSqlUtil::get_table
OracleTable get_table(AbstractDatasource nds, string nname, *hash opts)
returns an OracleTable object corresponding to the arguments
hash
hash hash(object obj)
OracleSqlUtil::OracleView::container_data
bool container_data
Indicates whether the view contains container-specific data.
Definition: OracleSqlUtil.qm.dox.h:600
OracleSqlUtil::OracleDatabase::OracleSchemaDescriptionOptions
const OracleSchemaDescriptionOptions
oracle-specific schema description keys
Definition: OracleSqlUtil.qm.dox.h:791
SZ_OPT
const SZ_OPT
OracleSqlUtil::OracleIndex::getCreateSql
string getCreateSql(string table_name, *hash opt)
returns a string that can be used to create the index in the database
OracleSqlUtil::OracleTable::OraColumnOptions
const OraColumnOptions
Oracle-specific column options.
Definition: OracleSqlUtil.qm.dox.h:1092
OracleSqlUtil::OracleForeignConstraint
represents an Oracle foreign constraint
Definition: OracleSqlUtil.qm.dox.h:391
SqlUtil::AbstractDatabase
OracleSqlUtil::OracleType
represents an Oracle type
Definition: OracleSqlUtil.qm.dox.h:676
OracleSqlUtil::OraclePrimaryKey
represents an Oracle primary key
Definition: OracleSqlUtil.qm.dox.h:504
OracleSqlUtil::OraclePrimaryKey::clearIndex
clearIndex()
clears any index base for the constraint
SqlUtil::AbstractPrimaryKey
OracleSqlUtil::OracleTable::getTablespaceName
*string getTablespaceName()
returns the data tablespace name for the table if any or NOTHING if none is known ...
OracleSqlUtil::OracleTable::doSelectLimitOnlyUnlockedImpl
private doSelectLimitOnlyUnlockedImpl(reference sql, reference args, *hash qh)
processes a string for use in SQL select statements when there is a &quot;limit&quot; argument, but no &quot;orderby&quot; or &quot;offset&quot; arguments
OracleSqlUtil::OracleIndex::native_type
string native_type
the native type of the index (if supported)
Definition: OracleSqlUtil.qm.dox.h:366
join
string join(string str,...)
SqlUtil::NUMERIC
const NUMERIC
Number
const Number
OracleSqlUtil::OracleDatabase::getNextSequenceValueImpl
private softint getNextSequenceValueImpl(string name)
returns the next value in the given sequence
OracleSqlUtil::OracleIndex
represents an Oracle index
Definition: OracleSqlUtil.qm.dox.h:361
DefaultOpMap
const DefaultOpMap
SqlUtil::AbstractUniqueConstraint
OracleSqlUtil::OracleColumn::char_used
bool char_used
the column uses character semantics
Definition: OracleSqlUtil.qm.dox.h:292
OracleSqlUtil::OracleFunction
represents an Oracle function
Definition: OracleSqlUtil.qm.dox.h:684
OracleSqlUtil::OracleCodeBase
the base class for Oracle code objects
Definition: OracleSqlUtil.qm.dox.h:651
OracleSqlUtil::OracleForeignConstraint::getDisableSql
string getDisableSql(string table_name)
returns a string that can be used to temporarily disable the constraint from the database ...