mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
2172 lines
78 KiB
ObjectPascal
2172 lines
78 KiB
ObjectPascal
{*********************************************************}
|
|
{ }
|
|
{ Zeos Database Objects }
|
|
{ Oracle Database Connectivity Classes }
|
|
{ }
|
|
{ Originally written by Sergey Seroukhov }
|
|
{ }
|
|
{*********************************************************}
|
|
|
|
{@********************************************************}
|
|
{ Copyright (c) 1999-2006 Zeos Development Group }
|
|
{ }
|
|
{ License Agreement: }
|
|
{ }
|
|
{ This library is distributed in the hope that it will be }
|
|
{ useful, but WITHOUT ANY WARRANTY; without even the }
|
|
{ implied warranty of MERCHANTABILITY or FITNESS FOR }
|
|
{ A PARTICULAR PURPOSE. See the GNU Lesser General }
|
|
{ Public License for more details. }
|
|
{ }
|
|
{ The source code of the ZEOS Libraries and packages are }
|
|
{ distributed under the Library GNU General Public }
|
|
{ License (see the file COPYING / COPYING.ZEOS) }
|
|
{ with the following modification: }
|
|
{ As a special exception, the copyright holders of this }
|
|
{ library give you permission to link this library with }
|
|
{ independent modules to produce an executable, }
|
|
{ regardless of the license terms of these independent }
|
|
{ modules, and to copy and distribute the resulting }
|
|
{ executable under terms of your choice, provided that }
|
|
{ you also meet, for each linked independent module, }
|
|
{ the terms and conditions of the license of that module. }
|
|
{ An independent module is a module which is not derived }
|
|
{ from or based on this library. If you modify this }
|
|
{ library, you may extend this exception to your version }
|
|
{ of the library, but you are not obligated to do so. }
|
|
{ If you do not wish to do so, delete this exception }
|
|
{ statement from your version. }
|
|
{ }
|
|
{ }
|
|
{ The project web site is located on: }
|
|
{ http://zeos.firmos.at (FORUM) }
|
|
{ http://zeosbugs.firmos.at (BUGTRACKER) }
|
|
{ svn://zeos.firmos.at/zeos/trunk (SVN Repository) }
|
|
{ }
|
|
{ http://www.sourceforge.net/projects/zeoslib. }
|
|
{ http://www.zeoslib.sourceforge.net }
|
|
{ }
|
|
{ }
|
|
{ }
|
|
{ Zeos Development Group. }
|
|
{********************************************************@}
|
|
|
|
unit ZDbcOracleMetadata;
|
|
|
|
interface
|
|
|
|
{$I ZDbc.inc}
|
|
|
|
uses
|
|
{$IFNDEF VER130BELOW}
|
|
Types,
|
|
{$ENDIF}
|
|
Classes, SysUtils, Contnrs, ZClasses, ZSysUtils, ZDbcIntfs, ZDbcMetadata,
|
|
ZDbcResultSetMetadata, ZCompatibility, ZDbcOracleUtils, ZDbcConnection;
|
|
|
|
type
|
|
|
|
{** Implements Oracle Database Metadata. }
|
|
TZOracleDatabaseMetadata = class(TZAbstractDatabaseMetadata)
|
|
private
|
|
FDatabase: string;
|
|
public
|
|
constructor Create(Connection: TZAbstractConnection; Url: string;
|
|
Info: TStrings);
|
|
destructor Destroy; override;
|
|
|
|
function GetDatabaseProductName: string; override;
|
|
function GetDatabaseProductVersion: string; override;
|
|
function GetDriverName: string; override;
|
|
function GetDriverMajorVersion: Integer; override;
|
|
function GetDriverMinorVersion: Integer; override;
|
|
function UsesLocalFilePerTable: Boolean; override;
|
|
function SupportsMixedCaseIdentifiers: Boolean; override;
|
|
function StoresUpperCaseIdentifiers: Boolean; override;
|
|
function StoresLowerCaseIdentifiers: Boolean; override;
|
|
function StoresMixedCaseIdentifiers: Boolean; override;
|
|
function SupportsMixedCaseQuotedIdentifiers: Boolean; override;
|
|
function StoresUpperCaseQuotedIdentifiers: Boolean; override;
|
|
function StoresLowerCaseQuotedIdentifiers: Boolean; override;
|
|
function StoresMixedCaseQuotedIdentifiers: Boolean; override;
|
|
function GetSQLKeywords: string; override;
|
|
function GetNumericFunctions: string; override;
|
|
function GetStringFunctions: string; override;
|
|
function GetSystemFunctions: string; override;
|
|
function GetTimeDateFunctions: string; override;
|
|
function GetSearchStringEscape: string; override;
|
|
function GetExtraNameCharacters: string; override;
|
|
|
|
function SupportsExpressionsInOrderBy: Boolean; override;
|
|
function SupportsOrderByUnrelated: Boolean; override;
|
|
function SupportsGroupBy: Boolean; override;
|
|
function SupportsGroupByUnrelated: Boolean; override;
|
|
function SupportsGroupByBeyondSelect: Boolean; override;
|
|
function SupportsIntegrityEnhancementFacility: Boolean; override;
|
|
function GetSchemaTerm: string; override;
|
|
function GetProcedureTerm: string; override;
|
|
function GetCatalogTerm: string; override;
|
|
function GetCatalogSeparator: string; override;
|
|
function SupportsSchemasInDataManipulation: Boolean; override;
|
|
function SupportsSchemasInProcedureCalls: Boolean; override;
|
|
function SupportsSchemasInTableDefinitions: Boolean; override;
|
|
function SupportsSchemasInIndexDefinitions: Boolean; override;
|
|
function SupportsSchemasInPrivilegeDefinitions: Boolean; override;
|
|
function SupportsCatalogsInDataManipulation: Boolean; override;
|
|
function SupportsCatalogsInProcedureCalls: Boolean; override;
|
|
function SupportsCatalogsInTableDefinitions: Boolean; override;
|
|
function SupportsCatalogsInIndexDefinitions: Boolean; override;
|
|
function SupportsCatalogsInPrivilegeDefinitions: Boolean; override;
|
|
function SupportsPositionedDelete: Boolean; override;
|
|
function SupportsPositionedUpdate: Boolean; override;
|
|
function SupportsSelectForUpdate: Boolean; override;
|
|
function SupportsStoredProcedures: Boolean; override;
|
|
function SupportsSubqueriesInComparisons: Boolean; override;
|
|
function SupportsSubqueriesInExists: Boolean; override;
|
|
function SupportsSubqueriesInIns: Boolean; override;
|
|
function SupportsSubqueriesInQuantifieds: Boolean; override;
|
|
function SupportsCorrelatedSubqueries: Boolean; override;
|
|
function SupportsUnion: Boolean; override;
|
|
function SupportsUnionAll: Boolean; override;
|
|
function SupportsOpenCursorsAcrossCommit: Boolean; override;
|
|
function SupportsOpenCursorsAcrossRollback: Boolean; override;
|
|
function SupportsOpenStatementsAcrossCommit: Boolean; override;
|
|
function SupportsOpenStatementsAcrossRollback: Boolean; override;
|
|
|
|
function GetMaxBinaryLiteralLength: Integer; override;
|
|
function GetMaxCharLiteralLength: Integer; override;
|
|
function GetMaxColumnNameLength: Integer; override;
|
|
function GetMaxColumnsInGroupBy: Integer; override;
|
|
function GetMaxColumnsInIndex: Integer; override;
|
|
function GetMaxColumnsInOrderBy: Integer; override;
|
|
function GetMaxColumnsInSelect: Integer; override;
|
|
function GetMaxColumnsInTable: Integer; override;
|
|
function GetMaxConnections: Integer; override;
|
|
function GetMaxCursorNameLength: Integer; override;
|
|
function GetMaxIndexLength: Integer; override;
|
|
function GetMaxSchemaNameLength: Integer; override;
|
|
function GetMaxProcedureNameLength: Integer; override;
|
|
function GetMaxCatalogNameLength: Integer; override;
|
|
function GetMaxRowSize: Integer; override;
|
|
function DoesMaxRowSizeIncludeBlobs: Boolean; override;
|
|
function GetMaxStatementLength: Integer; override;
|
|
function GetMaxStatements: Integer; override;
|
|
function GetMaxTableNameLength: Integer; override;
|
|
function GetMaxTablesInSelect: Integer; override;
|
|
function GetMaxUserNameLength: Integer; override;
|
|
|
|
function GetDefaultTransactionIsolation: TZTransactIsolationLevel; override;
|
|
function SupportsTransactions: Boolean; override;
|
|
function SupportsTransactionIsolationLevel(Level: TZTransactIsolationLevel):
|
|
Boolean; override;
|
|
function SupportsDataDefinitionAndDataManipulationTransactions: Boolean;
|
|
override;
|
|
function SupportsDataManipulationTransactionsOnly: Boolean; override;
|
|
function DataDefinitionCausesTransactionCommit: Boolean; override;
|
|
function DataDefinitionIgnoredInTransactions: Boolean; override;
|
|
|
|
function GetProcedures(const Catalog: string; const SchemaPattern: string;
|
|
const ProcedureNamePattern: string): IZResultSet; override;
|
|
function GetProcedureColumns(const Catalog: string; const SchemaPattern: string;
|
|
const ProcedureNamePattern: string; const ColumnNamePattern: string):
|
|
IZResultSet; override;
|
|
|
|
function GetTables(const Catalog: string; const SchemaPattern: string;
|
|
const TableNamePattern: string; const Types: TStringDynArray): IZResultSet; override;
|
|
function GetSchemas: IZResultSet; override;
|
|
function GetCatalogs: IZResultSet; override;
|
|
function GetTableTypes: IZResultSet; override;
|
|
function GetColumns(const Catalog: string; const SchemaPattern: string;
|
|
const TableNamePattern: string; const ColumnNamePattern: string): IZResultSet; override;
|
|
function GetColumnPrivileges(const Catalog: string; const Schema: string;
|
|
const Table: string; const ColumnNamePattern: string): IZResultSet; override;
|
|
|
|
function GetTablePrivileges(const Catalog: string; const SchemaPattern: string;
|
|
const TableNamePattern: string): IZResultSet; override;
|
|
function GetVersionColumns(const Catalog: string; const Schema: string;
|
|
const Table: string): IZResultSet; override;
|
|
|
|
function GetPrimaryKeys(const Catalog: string; const Schema: string;
|
|
const Table: string): IZResultSet; override;
|
|
function GetImportedKeys(const Catalog: string; const Schema: string;
|
|
const Table: string): IZResultSet; override;
|
|
function GetExportedKeys(const Catalog: string; const Schema: string;
|
|
const Table: string): IZResultSet; override;
|
|
function GetCrossReference(const PrimaryCatalog: string; const PrimarySchema: string;
|
|
const PrimaryTable: string; const ForeignCatalog: string; const ForeignSchema: string;
|
|
const ForeignTable: string): IZResultSet; override;
|
|
|
|
function GetTypeInfo: IZResultSet; override;
|
|
|
|
function GetIndexInfo(const Catalog: string; const Schema: string; const Table: string;
|
|
Unique: Boolean; Approximate: Boolean): IZResultSet; override;
|
|
|
|
function SupportsResultSetType(_Type: TZResultSetType): Boolean; override;
|
|
function SupportsResultSetConcurrency(_Type: TZResultSetType;
|
|
Concurrency: TZResultSetConcurrency): Boolean; override;
|
|
|
|
function GetUDTs(const Catalog: string; const SchemaPattern: string;
|
|
const TypeNamePattern: string; const Types: TIntegerDynArray): IZResultSet; override;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
Math, ZMessages, ZDbcUtils, ZDbcOracle;
|
|
|
|
{ TZOracleDatabaseMetadata }
|
|
|
|
{**
|
|
Constructs this object and assignes the main properties.
|
|
@param Connection a database connection object.
|
|
@param Url a database connection url string.
|
|
@param Info an extra connection properties.
|
|
}
|
|
constructor TZOracleDatabaseMetadata.Create(
|
|
Connection: TZAbstractConnection; Url: string; Info: TStrings);
|
|
var
|
|
TempInfo: TStrings;
|
|
HostName, UserName, Password: string;
|
|
Port: Integer;
|
|
SocketName: string;
|
|
begin
|
|
inherited Create(Connection, Url, Info);
|
|
|
|
TempInfo := TStringList.Create;
|
|
try
|
|
ResolveDatabaseUrl(Url, Info, HostName, Port, SocketName, FDatabase,
|
|
UserName, Password, TempInfo);
|
|
finally
|
|
TempInfo.Free;
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Destroys this object and cleanups the memory.
|
|
}
|
|
destructor TZOracleDatabaseMetadata.Destroy;
|
|
begin
|
|
inherited Destroy;
|
|
end;
|
|
|
|
//----------------------------------------------------------------------
|
|
// First, a variety of minor information about the target database.
|
|
|
|
{**
|
|
What's the name of this database product?
|
|
@return database product name
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDatabaseProductName: string;
|
|
begin
|
|
Result := 'Oracle';
|
|
end;
|
|
|
|
{**
|
|
What's the version of this database product?
|
|
@return database version
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDatabaseProductVersion: string;
|
|
begin
|
|
Result := '';
|
|
end;
|
|
|
|
{**
|
|
What's the name of this JDBC driver?
|
|
@return JDBC driver name
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDriverName: string;
|
|
begin
|
|
Result := 'Zeos Database Connectivity Driver for Oracle';
|
|
end;
|
|
|
|
{**
|
|
What's this JDBC driver's major version number?
|
|
@return JDBC driver major version
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDriverMajorVersion: Integer;
|
|
begin
|
|
Result := 1;
|
|
end;
|
|
|
|
{**
|
|
What's this JDBC driver's minor version number?
|
|
@return JDBC driver minor version number
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDriverMinorVersion: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
Does the database use a file for each table?
|
|
@return true if the database uses a local file for each table
|
|
}
|
|
function TZOracleDatabaseMetadata.UsesLocalFilePerTable: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case unquoted SQL identifiers as
|
|
case sensitive and as a result store them in mixed case?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return false.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsMixedCaseIdentifiers: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case unquoted SQL identifiers as
|
|
case insensitive and store them in upper case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresUpperCaseIdentifiers: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case unquoted SQL identifiers as
|
|
case insensitive and store them in lower case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresLowerCaseIdentifiers: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case unquoted SQL identifiers as
|
|
case insensitive and store them in mixed case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresMixedCaseIdentifiers: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case quoted SQL identifiers as
|
|
case sensitive and as a result store them in mixed case?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsMixedCaseQuotedIdentifiers: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case quoted SQL identifiers as
|
|
case insensitive and store them in upper case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresUpperCaseQuotedIdentifiers: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case quoted SQL identifiers as
|
|
case insensitive and store them in lower case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresLowerCaseQuotedIdentifiers: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Does the database treat mixed case quoted SQL identifiers as
|
|
case insensitive and store them in mixed case?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.StoresMixedCaseQuotedIdentifiers: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Gets a comma-separated list of all a database's SQL keywords
|
|
that are NOT also SQL92 keywords.
|
|
@return the list
|
|
}
|
|
function TZOracleDatabaseMetadata.GetSQLKeywords: string;
|
|
begin
|
|
Result := 'ACCESS,ADD,ALTER,AUDIT,CLUSTER,COLUMN,COMMENT,COMPRESS,CONNECT,'
|
|
+ 'DATE,DROP,EXCLUSIVE,FILE,IDENTIFIED,IMMEDIATE,INCREMENT,INDEX,INITIAL,'
|
|
+ 'INTERSECT,LEVEL,LOCK,LONG,MAXEXTENTS,MINUS,MODE,NOAUDIT,NOCOMPRESS,'
|
|
+ 'NOWAIT,NUMBER,OFFLINE,ONLINE,PCTFREE,PRIOR';
|
|
end;
|
|
|
|
{**
|
|
Gets a comma-separated list of math functions. These are the
|
|
X/Open CLI math function names used in the JDBC function escape
|
|
clause.
|
|
@return the list
|
|
}
|
|
function TZOracleDatabaseMetadata.GetNumericFunctions: string;
|
|
begin
|
|
Result := 'ABS,ACOS,ASIN,ATAN,ATAN2,CEILING,COS,EXP,FLOOR,LOG,LOG10,MOD,PI,'
|
|
+ 'POWER,ROUND,SIGN,SIN,SQRT,TAN,TRUNCATE';
|
|
end;
|
|
|
|
{**
|
|
Gets a comma-separated list of string functions. These are the
|
|
X/Open CLI string function names used in the JDBC function escape
|
|
clause.
|
|
@return the list
|
|
}
|
|
function TZOracleDatabaseMetadata.GetStringFunctions: string;
|
|
begin
|
|
Result := 'ASCII,CHAR,CONCAT,LCASE,LENGTH,LTRIM,REPLACE,RTRIM,SOUNDEX,'
|
|
+ 'SUBSTRING,UCASE';
|
|
end;
|
|
|
|
{**
|
|
Gets a comma-separated list of system functions. These are the
|
|
X/Open CLI system function names used in the JDBC function escape
|
|
clause.
|
|
@return the list
|
|
}
|
|
function TZOracleDatabaseMetadata.GetSystemFunctions: string;
|
|
begin
|
|
Result := 'USER';
|
|
end;
|
|
|
|
{**
|
|
Gets a comma-separated list of time and date functions.
|
|
@return the list
|
|
}
|
|
function TZOracleDatabaseMetadata.GetTimeDateFunctions: string;
|
|
begin
|
|
Result := 'CURDATE,CURTIME,DAYOFMONTH,HOUR,MINUTE,MONTH,NOW,SECOND,YEAR';
|
|
end;
|
|
|
|
{**
|
|
Gets the string that can be used to escape wildcard characters.
|
|
This is the string that can be used to escape '_' or '%' in
|
|
the string pattern style catalog search parameters.
|
|
|
|
<P>The '_' character represents any single character.
|
|
<P>The '%' character represents any sequence of zero or
|
|
more characters.
|
|
|
|
@return the string used to escape wildcard characters
|
|
}
|
|
function TZOracleDatabaseMetadata.GetSearchStringEscape: string;
|
|
begin
|
|
Result := '//';
|
|
end;
|
|
|
|
{**
|
|
Gets all the "extra" characters that can be used in unquoted
|
|
identifier names (those beyond a-z, A-Z, 0-9 and _).
|
|
@return the string containing the extra characters
|
|
}
|
|
function TZOracleDatabaseMetadata.GetExtraNameCharacters: string;
|
|
begin
|
|
Result := '$#';
|
|
end;
|
|
|
|
//--------------------------------------------------------------------
|
|
// Functions describing which features are supported.
|
|
|
|
{**
|
|
Are expressions in "ORDER BY" lists supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsExpressionsInOrderBy: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can an "ORDER BY" clause use columns not in the SELECT statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsOrderByUnrelated: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Is some form of "GROUP BY" clause supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsGroupBy: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a "GROUP BY" clause use columns not in the SELECT?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsGroupByUnrelated: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a "GROUP BY" clause add columns not in the SELECT
|
|
provided it specifies all the columns in the SELECT?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsGroupByBeyondSelect: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Is the SQL Integrity Enhancement Facility supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsIntegrityEnhancementFacility: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
What's the database vendor's preferred term for "schema"?
|
|
@return the vendor term
|
|
}
|
|
function TZOracleDatabaseMetadata.GetSchemaTerm: string;
|
|
begin
|
|
Result := 'schema';
|
|
end;
|
|
|
|
{**
|
|
What's the database vendor's preferred term for "procedure"?
|
|
@return the vendor term
|
|
}
|
|
function TZOracleDatabaseMetadata.GetProcedureTerm: string;
|
|
begin
|
|
Result := 'procedure';
|
|
end;
|
|
|
|
{**
|
|
What's the database vendor's preferred term for "catalog"?
|
|
@return the vendor term
|
|
}
|
|
function TZOracleDatabaseMetadata.GetCatalogTerm: string;
|
|
begin
|
|
Result := '';
|
|
end;
|
|
|
|
{**
|
|
What's the separator between catalog and table name?
|
|
@return the separator string
|
|
}
|
|
function TZOracleDatabaseMetadata.GetCatalogSeparator: string;
|
|
begin
|
|
Result := '';
|
|
end;
|
|
|
|
{**
|
|
Can a schema name be used in a data manipulation statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSchemasInDataManipulation: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a schema name be used in a procedure call statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSchemasInProcedureCalls: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a schema name be used in a table definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSchemasInTableDefinitions: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a schema name be used in an index definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSchemasInIndexDefinitions: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a schema name be used in a privilege definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSchemasInPrivilegeDefinitions: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can a catalog name be used in a data manipulation statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCatalogsInDataManipulation: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can a catalog name be used in a procedure call statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCatalogsInProcedureCalls: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can a catalog name be used in a table definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCatalogsInTableDefinitions: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can a catalog name be used in an index definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCatalogsInIndexDefinitions: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can a catalog name be used in a privilege definition statement?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCatalogsInPrivilegeDefinitions: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Is positioned DELETE supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsPositionedDelete: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Is positioned UPDATE supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsPositionedUpdate: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Is SELECT for UPDATE supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSelectForUpdate: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are stored procedure calls using the stored procedure escape
|
|
syntax supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsStoredProcedures: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are subqueries in comparison expressions supported?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSubqueriesInComparisons: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are subqueries in 'exists' expressions supported?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSubqueriesInExists: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are subqueries in 'in' statements supported?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSubqueriesInIns: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are subqueries in quantified expressions supported?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsSubqueriesInQuantifieds: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are correlated subqueries supported?
|
|
A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsCorrelatedSubqueries: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Is SQL UNION supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsUnion: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Is SQL UNION ALL supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsUnionAll: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Can cursors remain open across commits?
|
|
@return <code>true</code> if cursors always remain open;
|
|
<code>false</code> if they might not remain open
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsOpenCursorsAcrossCommit: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can cursors remain open across rollbacks?
|
|
@return <code>true</code> if cursors always remain open;
|
|
<code>false</code> if they might not remain open
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsOpenCursorsAcrossRollback: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can statements remain open across commits?
|
|
@return <code>true</code> if statements always remain open;
|
|
<code>false</code> if they might not remain open
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsOpenStatementsAcrossCommit: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Can statements remain open across rollbacks?
|
|
@return <code>true</code> if statements always remain open;
|
|
<code>false</code> if they might not remain open
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsOpenStatementsAcrossRollback: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
//----------------------------------------------------------------------
|
|
// The following group of methods exposes various limitations
|
|
// based on the target database with the current driver.
|
|
// Unless otherwise specified, a result of zero means there is no
|
|
// limit, or the limit is not known.
|
|
|
|
{**
|
|
How many hex characters can you have in an inline binary literal?
|
|
@return max binary literal length in hex characters;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxBinaryLiteralLength: Integer;
|
|
begin
|
|
Result := 1000;
|
|
end;
|
|
|
|
{**
|
|
What's the max length for a character literal?
|
|
@return max literal length;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxCharLiteralLength: Integer;
|
|
begin
|
|
Result := 2000;
|
|
end;
|
|
|
|
{**
|
|
What's the limit on column name length?
|
|
@return max column name length;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnNameLength: Integer;
|
|
begin
|
|
Result := 30;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of columns in a "GROUP BY" clause?
|
|
@return max number of columns;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnsInGroupBy: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of columns allowed in an index?
|
|
@return max number of columns;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnsInIndex: Integer;
|
|
begin
|
|
Result := 32;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of columns in an "ORDER BY" clause?
|
|
@return max number of columns;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnsInOrderBy: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of columns in a "SELECT" list?
|
|
@return max number of columns;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnsInSelect: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of columns in a table?
|
|
@return max number of columns;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxColumnsInTable: Integer;
|
|
begin
|
|
Result := 1000;
|
|
end;
|
|
|
|
{**
|
|
How many active connections can we have at a time to this database?
|
|
@return max number of active connections;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxConnections: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum cursor name length?
|
|
@return max cursor name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxCursorNameLength: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
Retrieves the maximum number of bytes for an index, including all
|
|
of the parts of the index.
|
|
@return max index length in bytes, which includes the composite of all
|
|
the constituent parts of the index;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxIndexLength: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length allowed for a schema name?
|
|
@return max name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxSchemaNameLength: Integer;
|
|
begin
|
|
Result := 30;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of a procedure name?
|
|
@return max name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxProcedureNameLength: Integer;
|
|
begin
|
|
Result := 30;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of a catalog name?
|
|
@return max name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxCatalogNameLength: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of a single row?
|
|
@return max row size in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxRowSize: Integer;
|
|
begin
|
|
Result := 2000;
|
|
end;
|
|
|
|
{**
|
|
Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
|
|
blobs?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.DoesMaxRowSizeIncludeBlobs: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of an SQL statement?
|
|
@return max length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxStatementLength: Integer;
|
|
begin
|
|
Result := 65535;
|
|
end;
|
|
|
|
{**
|
|
How many active statements can we have open at one time to this
|
|
database?
|
|
@return the maximum number of statements that can be open at one time;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxStatements: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of a table name?
|
|
@return max name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxTableNameLength: Integer;
|
|
begin
|
|
Result := 30;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum number of tables in a SELECT statement?
|
|
@return the maximum number of tables allowed in a SELECT statement;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxTablesInSelect: Integer;
|
|
begin
|
|
Result := 0;
|
|
end;
|
|
|
|
{**
|
|
What's the maximum length of a user name?
|
|
@return max user name length in bytes;
|
|
a result of zero means that there is no limit or the limit is not known
|
|
}
|
|
function TZOracleDatabaseMetadata.GetMaxUserNameLength: Integer;
|
|
begin
|
|
Result := 30;
|
|
end;
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
{**
|
|
What's the database's default transaction isolation level? The
|
|
values are defined in <code>java.sql.Connection</code>.
|
|
@return the default isolation level
|
|
@see Connection
|
|
}
|
|
function TZOracleDatabaseMetadata.GetDefaultTransactionIsolation:
|
|
TZTransactIsolationLevel;
|
|
begin
|
|
Result := tiReadCommitted;
|
|
end;
|
|
|
|
{**
|
|
Are transactions supported? If not, invoking the method
|
|
<code>commit</code> is a noop and the isolation level is TRANSACTION_NONE.
|
|
@return <code>true</code> if transactions are supported; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsTransactions: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Does this database support the given transaction isolation level?
|
|
@param level the values are defined in <code>java.sql.Connection</code>
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
@see Connection
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsTransactionIsolationLevel(
|
|
Level: TZTransactIsolationLevel): Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are both data definition and data manipulation statements
|
|
within a transaction supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.
|
|
SupportsDataDefinitionAndDataManipulationTransactions: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Are only data manipulation statements within a transaction
|
|
supported?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.
|
|
SupportsDataManipulationTransactionsOnly: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Does a data definition statement within a transaction force the
|
|
transaction to commit?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.DataDefinitionCausesTransactionCommit: Boolean;
|
|
begin
|
|
Result := True;
|
|
end;
|
|
|
|
{**
|
|
Is a data definition statement within a transaction ignored?
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.DataDefinitionIgnoredInTransactions: Boolean;
|
|
begin
|
|
Result := False;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the stored procedures available in a
|
|
catalog.
|
|
|
|
<P>Only procedure descriptions matching the schema and
|
|
procedure name criteria are returned. They are ordered by
|
|
PROCEDURE_SCHEM, and PROCEDURE_NAME.
|
|
|
|
<P>Each procedure description has the the following columns:
|
|
<OL>
|
|
<LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
|
|
<LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
|
|
<LI><B>PROCEDURE_NAME</B> String => procedure name
|
|
<LI> reserved for future use
|
|
<LI> reserved for future use
|
|
<LI> reserved for future use
|
|
<LI><B>REMARKS</B> String => explanatory comment on the procedure
|
|
<LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
|
|
<UL>
|
|
<LI> procedureResultUnknown - May return a result
|
|
<LI> procedureNoResult - Does not return a result
|
|
<LI> procedureReturnsResult - Returns a result
|
|
</UL>
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param procedureNamePattern a procedure name pattern
|
|
@return <code>ResultSet</code> - each row is a procedure description
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetProcedures(const Catalog: string;
|
|
const SchemaPattern: string; const ProcedureNamePattern: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetProcedures(
|
|
Catalog, SchemaPattern, ProcedureNamePattern);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of a catalog's stored procedure parameters
|
|
and result columns.
|
|
|
|
<P>Only descriptions matching the schema, procedure and
|
|
parameter name criteria are returned. They are ordered by
|
|
PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
|
|
if any, is first. Next are the parameter descriptions in call
|
|
order. The column descriptions follow in column number order.
|
|
|
|
<P>Each row in the <code>ResultSet</code> is a parameter description or
|
|
column description with the following fields:
|
|
<OL>
|
|
<LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
|
|
<LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
|
|
<LI><B>PROCEDURE_NAME</B> String => procedure name
|
|
<LI><B>COLUMN_NAME</B> String => column/parameter name
|
|
<LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
|
|
<UL>
|
|
<LI> procedureColumnUnknown - nobody knows
|
|
<LI> procedureColumnIn - IN parameter
|
|
<LI> procedureColumnInOut - INOUT parameter
|
|
<LI> procedureColumnOut - OUT parameter
|
|
<LI> procedureColumnReturn - procedure return value
|
|
<LI> procedureColumnResult - result column in <code>ResultSet</code>
|
|
</UL>
|
|
<LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
|
|
<LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the
|
|
type name is fully qualified
|
|
<LI><B>PRECISION</B> int => precision
|
|
<LI><B>LENGTH</B> int => length in bytes of data
|
|
<LI><B>SCALE</B> short => scale
|
|
<LI><B>RADIX</B> short => radix
|
|
<LI><B>NULLABLE</B> short => can it contain NULL?
|
|
<UL>
|
|
<LI> procedureNoNulls - does not allow NULL values
|
|
<LI> procedureNullable - allows NULL values
|
|
<LI> procedureNullableUnknown - nullability unknown
|
|
</UL>
|
|
<LI><B>REMARKS</B> String => comment describing parameter/column
|
|
</OL>
|
|
|
|
<P><B>Note:</B> Some databases may not return the column
|
|
descriptions for a procedure. Additional columns beyond
|
|
REMARKS can be defined by the database.
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param procedureNamePattern a procedure name pattern
|
|
@param columnNamePattern a column name pattern
|
|
@return <code>ResultSet</code> - each row describes a stored procedure parameter or
|
|
column
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetProcedureColumns(const Catalog: string;
|
|
const SchemaPattern: string; const ProcedureNamePattern: string;
|
|
const ColumnNamePattern: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetProcedureColumns(Catalog, SchemaPattern,
|
|
ProcedureNamePattern, ColumnNamePattern);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of tables available in a catalog.
|
|
|
|
<P>Only table descriptions matching the catalog, schema, table
|
|
name and type criteria are returned. They are ordered by
|
|
TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
|
|
|
|
<P>Each table description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
|
|
"VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
|
|
"LOCAL TEMPORARY", "ALIAS", "SYNONYM".
|
|
<LI><B>REMARKS</B> String => explanatory comment on the table
|
|
</OL>
|
|
|
|
<P><B>Note:</B> Some databases may not return information for
|
|
all tables.
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param tableNamePattern a table name pattern
|
|
@param types a list of table types to include; null returns all types
|
|
@return <code>ResultSet</code> - each row is a table description
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetTables(const Catalog: string;
|
|
const SchemaPattern: string; const TableNamePattern: string;
|
|
const Types: TStringDynArray): IZResultSet;
|
|
var
|
|
Key, PartSQL, SQL: string;
|
|
|
|
function IncludedType(const TypeName: string): Boolean;
|
|
var I: Integer;
|
|
begin
|
|
Result := False;
|
|
for I := Low(Types) to High(Types) do
|
|
Result := Result or (UpperCase(Types[I]) = TypeName);
|
|
Result := Result or (Length(Types) = 0);
|
|
end;
|
|
|
|
begin
|
|
Key := GetTablesMetaDataCacheKey(Catalog,SchemaPattern,TableNamePattern,Types);
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
if IncludedType('TABLE') then
|
|
begin
|
|
SQL := 'SELECT NULL AS TABLE_CAT, OWNER AS TABLE_SCHEM, TABLE_NAME,'
|
|
+ ' ''TABLE'' AS TABLE_TYPE, NULL AS REMARKS FROM SYS.ALL_TABLES'
|
|
+ ' WHERE OWNER LIKE ''' + ToLikeString(SchemaPattern) + ''' AND TABLE_NAME LIKE '''
|
|
+ ToLikeString(TableNamePattern) + '''';
|
|
end else
|
|
SQL := '';
|
|
|
|
if IncludedType('SYNONYM') then
|
|
begin
|
|
PartSQL := 'SELECT NULL AS TABLE_CAT, OWNER AS TABLE_SCHEM,'
|
|
+ ' SYNONYM_NAME AS TABLE_NAME, ''SYNONYM'' AS TABLE_TYPE,'
|
|
+ ' NULL AS REMARKS FROM SYS.ALL_SYNONYMS WHERE OWNER LIKE '''
|
|
+ ToLikeString(SchemaPattern) + ''' AND SYNONYM_NAME LIKE ''' + ToLikeString(TableNamePattern) + '''';
|
|
|
|
if SQL <> '' then
|
|
SQL := SQL + ' UNION ';
|
|
SQL := SQL + PartSQL;
|
|
end;
|
|
|
|
if IncludedType('VIEW') then
|
|
begin
|
|
PartSQL := 'SELECT NULL AS TABLE_CAT, OWNER AS TABLE_SCHEM,'
|
|
+ ' VIEW_NAME AS TABLE_NAME, ''VIEW'' AS TABLE_TYPE,'
|
|
+ ' NULL AS REMARKS FROM SYS.ALL_VIEWS WHERE OWNER LIKE '''
|
|
+ ToLikeString(SchemaPattern) + ''' AND VIEW_NAME LIKE ''' + ToLikeString(TableNamePattern) + '''';
|
|
|
|
if SQL <> '' then
|
|
SQL := SQL + ' UNION ';
|
|
SQL := SQL + PartSQL;
|
|
end;
|
|
|
|
if IncludedType('SEQUENCE') then
|
|
begin
|
|
PartSQL := 'SELECT NULL AS TABLE_CAT, SEQUENCE_OWNER AS TABLE_SCHEM,'
|
|
+ ' SEQUENCE_NAME AS TABLE_NAME, ''SEQUENCE'' AS TABLE_TYPE,'
|
|
+ ' NULL AS REMARKS FROM SYS.ALL_SEQUENCES WHERE SEQUENCE_OWNER LIKE '''
|
|
+ ToLikeString(SchemaPattern) + ''' AND SEQUENCE_NAME LIKE ''' + ToLikeString(TableNamePattern) + '''';
|
|
|
|
if SQL <> '' then
|
|
SQL := SQL + ' UNION ';
|
|
SQL := SQL + PartSQL;
|
|
end;
|
|
|
|
Result := CopyToVirtualResultSet(
|
|
GetConnection.CreateStatement.ExecuteQuery(SQL),
|
|
ConstructVirtualResultSet(TableColumnsDynArray));
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets the schema names available in this database. The results
|
|
are ordered by schema name.
|
|
|
|
<P>The schema column is:
|
|
<OL>
|
|
<LI><B>TABLE_SCHEM</B> String => schema name
|
|
</OL>
|
|
|
|
@return <code>ResultSet</code> - each row has a single String column that is a
|
|
schema name
|
|
}
|
|
function TZOracleDatabaseMetadata.GetSchemas: IZResultSet;
|
|
var
|
|
Key: string;
|
|
begin
|
|
Key := 'get-schemas';
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
Result := CopyToVirtualResultSet(
|
|
GetConnection.CreateStatement.ExecuteQuery(
|
|
'SELECT USERNAME AS TABLE_SCHEM FROM SYS.ALL_USERS'),
|
|
ConstructVirtualResultSet(SchemaColumnsDynArray));
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets the catalog names available in this database. The results
|
|
are ordered by catalog name.
|
|
|
|
<P>The catalog column is:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => catalog name
|
|
</OL>
|
|
|
|
@return <code>ResultSet</code> - each row has a single String column that is a
|
|
catalog name
|
|
}
|
|
function TZOracleDatabaseMetadata.GetCatalogs: IZResultSet;
|
|
begin
|
|
Result := inherited GetCatalogs;
|
|
end;
|
|
|
|
{**
|
|
Gets the table types available in this database. The results
|
|
are ordered by table type.
|
|
|
|
<P>The table type is:
|
|
<OL>
|
|
<LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
|
|
"VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
|
|
"LOCAL TEMPORARY", "ALIAS", "SYNONYM".
|
|
</OL>
|
|
|
|
@return <code>ResultSet</code> - each row has a single String column that is a
|
|
table type
|
|
}
|
|
function TZOracleDatabaseMetadata.GetTableTypes: IZResultSet;
|
|
const
|
|
TableTypeCount = 4;
|
|
Types: array [1..TableTypeCount] of string = (
|
|
'TABLE', 'SYNONYM', 'VIEW', 'SEQUENCE'
|
|
);
|
|
var
|
|
I: Integer;
|
|
Key: string;
|
|
begin
|
|
Key := 'get-table-types';
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
Result := ConstructVirtualResultSet(TableTypeColumnsDynArray);
|
|
|
|
for I := 1 to TableTypeCount do
|
|
begin
|
|
Result.MoveToInsertRow;
|
|
Result.UpdateString(1, Types[I]);
|
|
Result.InsertRow;
|
|
end;
|
|
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of table columns available in
|
|
the specified catalog.
|
|
|
|
<P>Only column descriptions matching the catalog, schema, table
|
|
and column name criteria are returned. They are ordered by
|
|
TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
|
|
|
|
<P>Each column description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>COLUMN_NAME</B> String => column name
|
|
<LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
|
|
<LI><B>TYPE_NAME</B> String => Data source dependent type name,
|
|
for a UDT the type name is fully qualified
|
|
<LI><B>COLUMN_SIZE</B> int => column size. For char or date
|
|
types this is the maximum number of characters, for numeric or
|
|
decimal types this is precision.
|
|
<LI><B>BUFFER_LENGTH</B> is not used.
|
|
<LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
|
|
<LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
|
|
<LI><B>NULLABLE</B> int => is NULL allowed?
|
|
<UL>
|
|
<LI> columnNoNulls - might not allow NULL values
|
|
<LI> columnNullable - definitely allows NULL values
|
|
<LI> columnNullableUnknown - nullability unknown
|
|
</UL>
|
|
<LI><B>REMARKS</B> String => comment describing column (may be null)
|
|
<LI><B>COLUMN_DEF</B> String => default value (may be null)
|
|
<LI><B>SQL_DATA_TYPE</B> int => unused
|
|
<LI><B>SQL_DATETIME_SUB</B> int => unused
|
|
<LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
|
|
maximum number of bytes in the column
|
|
<LI><B>ORDINAL_POSITION</B> int => index of column in table
|
|
(starting at 1)
|
|
<LI><B>IS_NULLABLE</B> String => "NO" means column definitely
|
|
does not allow NULL values; "YES" means the column might
|
|
allow NULL values. An empty string means nobody knows.
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param tableNamePattern a table name pattern
|
|
@param columnNamePattern a column name pattern
|
|
@return <code>ResultSet</code> - each row is a column description
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetColumns(const Catalog: string;
|
|
const SchemaPattern: string; const TableNamePattern: string;
|
|
const ColumnNamePattern: string): IZResultSet;
|
|
var
|
|
Key, SQL: string;
|
|
begin
|
|
Key := Format('get-columns:%s:%s:%s:%s',
|
|
[Catalog, SchemaPattern, TableNamePattern, ColumnNamePattern]);
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
Result := ConstructVirtualResultSet(TableColColumnsDynArray);
|
|
|
|
SQL := 'SELECT NULL, OWNER, TABLE_NAME, COLUMN_NAME, NULL, DATA_TYPE,'
|
|
+ ' DATA_LENGTH, NULL, DATA_PRECISION, DATA_SCALE, NULLABLE, NULL,'
|
|
+ ' DATA_DEFAULT, NULL, NULL, NULL, COLUMN_ID, NULLABLE'
|
|
+ ' FROM SYS.ALL_TAB_COLUMNS'
|
|
+ ' WHERE OWNER LIKE ''' + ToLikeString(SchemaPattern) + ''' AND TABLE_NAME LIKE '''
|
|
+ ToLikeString(TableNamePattern) + ''' AND COLUMN_NAME LIKE '''
|
|
+ ToLikeString(ColumnNamePattern) + '''';
|
|
|
|
with GetConnection.CreateStatement.ExecuteQuery(SQL) do
|
|
begin
|
|
while Next do
|
|
begin
|
|
Result.MoveToInsertRow;
|
|
Result.UpdateNull(1);
|
|
Result.UpdateString(2, GetString(2));
|
|
Result.UpdateString(3, GetString(3));
|
|
Result.UpdateString(4, GetString(4));
|
|
Result.UpdateInt(5, Ord(ConvertOracleTypeToSQLType(
|
|
GetString(6), GetInt(9), GetInt(10))));
|
|
Result.UpdateString(6, GetString(6));
|
|
Result.UpdateInt(7, GetInt(7));
|
|
Result.UpdateNull(8);
|
|
Result.UpdateInt(9, GetInt(9));
|
|
Result.UpdateInt(10, GetInt(10));
|
|
|
|
if UpperCase(GetString(11)) = 'N' then
|
|
begin
|
|
Result.UpdateInt(11, Ord(ntNoNulls));
|
|
Result.UpdateString(18, 'NO');
|
|
end
|
|
else
|
|
begin
|
|
Result.UpdateInt(11, Ord(ntNullable));
|
|
Result.UpdateString(18, 'YES');
|
|
end;
|
|
|
|
Result.UpdateNull(12);
|
|
Result.UpdateString(13, GetString(13));
|
|
Result.UpdateNull(14);
|
|
Result.UpdateNull(15);
|
|
Result.UpdateNull(16);
|
|
Result.UpdateInt(17, GetInt(17));
|
|
|
|
Result.UpdateNullByName('AUTO_INCREMENT');
|
|
Result.UpdateBooleanByName('CASE_SENSITIVE',
|
|
GetIdentifierConvertor.IsCaseSensitive(GetString(4)));
|
|
Result.UpdateBooleanByName('SEARCHABLE', True);
|
|
Result.UpdateBooleanByName('WRITABLE', True);
|
|
Result.UpdateBooleanByName('DEFINITELYWRITABLE', True);
|
|
Result.UpdateBooleanByName('READONLY', False);
|
|
|
|
Result.InsertRow;
|
|
end;
|
|
Close;
|
|
end;
|
|
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the access rights for a table's columns.
|
|
|
|
<P>Only privileges matching the column name criteria are
|
|
returned. They are ordered by COLUMN_NAME and PRIVILEGE.
|
|
|
|
<P>Each privilige description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>COLUMN_NAME</B> String => column name
|
|
<LI><B>GRANTOR</B> => grantor of access (may be null)
|
|
<LI><B>GRANTEE</B> String => grantee of access
|
|
<LI><B>PRIVILEGE</B> String => name of access (SELECT,
|
|
INSERT, UPDATE, REFRENCES, ...)
|
|
<LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
|
|
to grant to others; "NO" if not; null if unknown
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those without a schema
|
|
@param table a table name
|
|
@param columnNamePattern a column name pattern
|
|
@return <code>ResultSet</code> - each row is a column privilege description
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetColumnPrivileges(const Catalog: string;
|
|
const Schema: string; const Table: string; const ColumnNamePattern: string): IZResultSet;
|
|
var
|
|
Key, SQL: string;
|
|
begin
|
|
Key := Format('get-column-privileges:%s:%s:%s:%s',
|
|
[Catalog, Schema, Table, ColumnNamePattern]);
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
SQL := 'SELECT NULL AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME,'
|
|
+ ' COLUMN_NAME, GRANTOR, GRANTEE, PRIVILEGE, GRANTABLE AS IS_GRANTABLE'
|
|
+ ' FROM SYS.ALL_COL_PRIVS WHERE';
|
|
if Schema <> '' then
|
|
SQL := SQL + ' TABLE_SCHEMA=''' + Schema + ''' AND';
|
|
if Table <> '' then
|
|
SQL := SQL + ' TABLE_NAME=''' + Table + ''' AND';
|
|
SQL := SQL + ' COLUMN_NAME LIKE ''' + ToLikeString(ColumnNamePattern) + '''';
|
|
|
|
Result := CopyToVirtualResultSet(
|
|
GetConnection.CreateStatement.ExecuteQuery(SQL),
|
|
ConstructVirtualResultSet(TableColPrivColumnsDynArray));
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the access rights for each table available
|
|
in a catalog. Note that a table privilege applies to one or
|
|
more columns in the table. It would be wrong to assume that
|
|
this priviledge applies to all columns (this may be true for
|
|
some systems but is not true for all.)
|
|
|
|
<P>Only privileges matching the schema and table name
|
|
criteria are returned. They are ordered by TABLE_SCHEM,
|
|
TABLE_NAME, and PRIVILEGE.
|
|
|
|
<P>Each privilige description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>GRANTOR</B> => grantor of access (may be null)
|
|
<LI><B>GRANTEE</B> String => grantee of access
|
|
<LI><B>PRIVILEGE</B> String => name of access (SELECT,
|
|
INSERT, UPDATE, REFRENCES, ...)
|
|
<LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
|
|
to grant to others; "NO" if not; null if unknown
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param tableNamePattern a table name pattern
|
|
@return <code>ResultSet</code> - each row is a table privilege description
|
|
@see #getSearchStringEscape
|
|
}
|
|
function TZOracleDatabaseMetadata.GetTablePrivileges(const Catalog: string;
|
|
const SchemaPattern: string; const TableNamePattern: string): IZResultSet;
|
|
var
|
|
Key, SQL: string;
|
|
begin
|
|
Key := Format('get-table-privileges:%s:%s:%s',
|
|
[Catalog, SchemaPattern, TableNamePattern]);
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
SQL := 'SELECT NULL AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME,'
|
|
+ ' GRANTOR, GRANTEE, PRIVILEGE, GRANTABLE AS IS_GRANTABLE'
|
|
+ ' FROM SYS.ALL_TAB_PRIVS WHERE TABLE_SCHEMA LIKE ''' + ToLikeString(SchemaPattern)
|
|
+ ''' AND TABLE_NAME LIKE ''' + ToLikeString(TableNamePattern) + '''';
|
|
|
|
Result := CopyToVirtualResultSet(
|
|
GetConnection.CreateStatement.ExecuteQuery(SQL),
|
|
ConstructVirtualResultSet(TablePrivColumnsDynArray));
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of a table's columns that are automatically
|
|
updated when any value in a row is updated. They are
|
|
unordered.
|
|
|
|
<P>Each column description has the following columns:
|
|
<OL>
|
|
<LI><B>SCOPE</B> short => is not used
|
|
<LI><B>COLUMN_NAME</B> String => column name
|
|
<LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
|
|
<LI><B>TYPE_NAME</B> String => Data source dependent type name
|
|
<LI><B>COLUMN_SIZE</B> int => precision
|
|
<LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
|
|
<LI><B>DECIMAL_DIGITS</B> short => scale
|
|
<LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
|
|
like an Oracle ROWID
|
|
<UL>
|
|
<LI> versionColumnUnknown - may or may not be pseudo column
|
|
<LI> versionColumnNotPseudo - is NOT a pseudo column
|
|
<LI> versionColumnPseudo - is a pseudo column
|
|
</UL>
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those without a schema
|
|
@param table a table name
|
|
@return <code>ResultSet</code> - each row is a column description
|
|
@exception SQLException if a database access error occurs
|
|
}
|
|
function TZOracleDatabaseMetadata.GetVersionColumns(const Catalog: string;
|
|
const Schema: string; const Table: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetVersionColumns(Catalog, Schema, Table);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of a table's primary key columns. They
|
|
are ordered by COLUMN_NAME.
|
|
|
|
<P>Each primary key column description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>COLUMN_NAME</B> String => column name
|
|
<LI><B>KEY_SEQ</B> short => sequence number within primary key
|
|
<LI><B>PK_NAME</B> String => primary key name (may be null)
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those
|
|
without a schema
|
|
@param table a table name
|
|
@return <code>ResultSet</code> - each row is a primary key column description
|
|
@exception SQLException if a database access error occurs
|
|
}
|
|
function TZOracleDatabaseMetadata.GetPrimaryKeys(const Catalog: string;
|
|
const Schema: string; const Table: string): IZResultSet;
|
|
var
|
|
SQL, Key: string;
|
|
begin
|
|
Key := Format('get-primary-keys:%s:%s:%s', [Catalog, Schema, Table]);
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
SQL := 'SELECT NULL AS TABLE_CAT, A.OWNER AS TABLE_SCHEM, A.TABLE_NAME,'
|
|
+ ' B.COLUMN_NAME, B.COLUMN_POSITION AS KEY_SEQ, A.INDEX_NAME AS PK_NAME'
|
|
+ ' FROM ALL_INDEXES A, ALL_IND_COLUMNS B'
|
|
+ ' WHERE A.OWNER=B.INDEX_OWNER AND A.INDEX_NAME=B.INDEX_NAME'
|
|
+ ' AND A.TABLE_OWNER=B.TABLE_OWNER AND A.TABLE_NAME=B.TABLE_NAME'
|
|
+ ' AND A.UNIQUENESS=''UNIQUE'' AND A.GENERATED=''Y'''
|
|
+ ' AND A.INDEX_NAME LIKE ''SYS_%''';
|
|
if Schema <> '' then
|
|
SQL := SQL + ' AND A.OWNER=''' + Schema + '''';
|
|
if Table <> '' then
|
|
SQL := SQL + ' AND A.TABLE_OWNER=''' + Table + '''';
|
|
SQL := SQL + ' ORDER BY A.INDEX_NAME, B.COLUMN_POSITION';
|
|
|
|
Result := CopyToVirtualResultSet(
|
|
GetConnection.CreateStatement.ExecuteQuery(SQL),
|
|
ConstructVirtualResultSet(PrimaryKeyColumnsDynArray));
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the primary key columns that are
|
|
referenced by a table's foreign key columns (the primary keys
|
|
imported by a table). They are ordered by PKTABLE_CAT,
|
|
PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
|
|
|
|
<P>Each primary key column description has the following columns:
|
|
<OL>
|
|
<LI><B>PKTABLE_CAT</B> String => primary key table catalog
|
|
being imported (may be null)
|
|
<LI><B>PKTABLE_SCHEM</B> String => primary key table schema
|
|
being imported (may be null)
|
|
<LI><B>PKTABLE_NAME</B> String => primary key table name
|
|
being imported
|
|
<LI><B>PKCOLUMN_NAME</B> String => primary key column name
|
|
being imported
|
|
<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
|
|
<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
|
|
<LI><B>FKTABLE_NAME</B> String => foreign key table name
|
|
<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
|
|
<LI><B>KEY_SEQ</B> short => sequence number within foreign key
|
|
<LI><B>UPDATE_RULE</B> short => What happens to
|
|
foreign key when primary is updated:
|
|
<UL>
|
|
<LI> importedNoAction - do not allow update of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - change imported key to agree
|
|
with primary key update
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been updated
|
|
<LI> importedKeySetDefault - change imported key to default values
|
|
if its primary key has been updated
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
</UL>
|
|
<LI><B>DELETE_RULE</B> short => What happens to
|
|
the foreign key when primary is deleted.
|
|
<UL>
|
|
<LI> importedKeyNoAction - do not allow delete of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - delete rows that import a deleted key
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been deleted
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
<LI> importedKeySetDefault - change imported key to default if
|
|
its primary key has been deleted
|
|
</UL>
|
|
<LI><B>FK_NAME</B> String => foreign key name (may be null)
|
|
<LI><B>PK_NAME</B> String => primary key name (may be null)
|
|
<LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
|
|
constraints be deferred until commit
|
|
<UL>
|
|
<LI> importedKeyInitiallyDeferred - see SQL92 for definition
|
|
<LI> importedKeyInitiallyImmediate - see SQL92 for definition
|
|
<LI> importedKeyNotDeferrable - see SQL92 for definition
|
|
</UL>
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those
|
|
without a schema
|
|
@param table a table name
|
|
@return <code>ResultSet</code> - each row is a primary key column description
|
|
@see #getExportedKeys
|
|
}
|
|
function TZOracleDatabaseMetadata.GetImportedKeys(const Catalog: string;
|
|
const Schema: string; const Table: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetImportedKeys(Catalog, Schema, Table);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the foreign key columns that reference a
|
|
table's primary key columns (the foreign keys exported by a
|
|
table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
|
|
FKTABLE_NAME, and KEY_SEQ.
|
|
|
|
<P>Each foreign key column description has the following columns:
|
|
<OL>
|
|
<LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
|
|
<LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
|
|
<LI><B>PKTABLE_NAME</B> String => primary key table name
|
|
<LI><B>PKCOLUMN_NAME</B> String => primary key column name
|
|
<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
|
|
being exported (may be null)
|
|
<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
|
|
being exported (may be null)
|
|
<LI><B>FKTABLE_NAME</B> String => foreign key table name
|
|
being exported
|
|
<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
|
|
being exported
|
|
<LI><B>KEY_SEQ</B> short => sequence number within foreign key
|
|
<LI><B>UPDATE_RULE</B> short => What happens to
|
|
foreign key when primary is updated:
|
|
<UL>
|
|
<LI> importedNoAction - do not allow update of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - change imported key to agree
|
|
with primary key update
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been updated
|
|
<LI> importedKeySetDefault - change imported key to default values
|
|
if its primary key has been updated
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
</UL>
|
|
<LI><B>DELETE_RULE</B> short => What happens to
|
|
the foreign key when primary is deleted.
|
|
<UL>
|
|
<LI> importedKeyNoAction - do not allow delete of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - delete rows that import a deleted key
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been deleted
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
<LI> importedKeySetDefault - change imported key to default if
|
|
its primary key has been deleted
|
|
</UL>
|
|
<LI><B>FK_NAME</B> String => foreign key name (may be null)
|
|
<LI><B>PK_NAME</B> String => primary key name (may be null)
|
|
<LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
|
|
constraints be deferred until commit
|
|
<UL>
|
|
<LI> importedKeyInitiallyDeferred - see SQL92 for definition
|
|
<LI> importedKeyInitiallyImmediate - see SQL92 for definition
|
|
<LI> importedKeyNotDeferrable - see SQL92 for definition
|
|
</UL>
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those
|
|
without a schema
|
|
@param table a table name
|
|
@return <code>ResultSet</code> - each row is a foreign key column description
|
|
@see #getImportedKeys
|
|
}
|
|
function TZOracleDatabaseMetadata.GetExportedKeys(const Catalog: string;
|
|
const Schema: string; const Table: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetExportedKeys(Catalog, Schema, Table);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the foreign key columns in the foreign key
|
|
table that reference the primary key columns of the primary key
|
|
table (describe how one table imports another's key.) This
|
|
should normally return a single foreign key/primary key pair
|
|
(most tables only import a foreign key from a table once.) They
|
|
are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
|
|
KEY_SEQ.
|
|
|
|
<P>Each foreign key column description has the following columns:
|
|
<OL>
|
|
<LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
|
|
<LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
|
|
<LI><B>PKTABLE_NAME</B> String => primary key table name
|
|
<LI><B>PKCOLUMN_NAME</B> String => primary key column name
|
|
<LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
|
|
being exported (may be null)
|
|
<LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
|
|
being exported (may be null)
|
|
<LI><B>FKTABLE_NAME</B> String => foreign key table name
|
|
being exported
|
|
<LI><B>FKCOLUMN_NAME</B> String => foreign key column name
|
|
being exported
|
|
<LI><B>KEY_SEQ</B> short => sequence number within foreign key
|
|
<LI><B>UPDATE_RULE</B> short => What happens to
|
|
foreign key when primary is updated:
|
|
<UL>
|
|
<LI> importedNoAction - do not allow update of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - change imported key to agree
|
|
with primary key update
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been updated
|
|
<LI> importedKeySetDefault - change imported key to default values
|
|
if its primary key has been updated
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
</UL>
|
|
<LI><B>DELETE_RULE</B> short => What happens to
|
|
the foreign key when primary is deleted.
|
|
<UL>
|
|
<LI> importedKeyNoAction - do not allow delete of primary
|
|
key if it has been imported
|
|
<LI> importedKeyCascade - delete rows that import a deleted key
|
|
<LI> importedKeySetNull - change imported key to NULL if
|
|
its primary key has been deleted
|
|
<LI> importedKeyRestrict - same as importedKeyNoAction
|
|
(for ODBC 2.x compatibility)
|
|
<LI> importedKeySetDefault - change imported key to default if
|
|
its primary key has been deleted
|
|
</UL>
|
|
<LI><B>FK_NAME</B> String => foreign key name (may be null)
|
|
<LI><B>PK_NAME</B> String => primary key name (may be null)
|
|
<LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
|
|
constraints be deferred until commit
|
|
<UL>
|
|
<LI> importedKeyInitiallyDeferred - see SQL92 for definition
|
|
<LI> importedKeyInitiallyImmediate - see SQL92 for definition
|
|
<LI> importedKeyNotDeferrable - see SQL92 for definition
|
|
</UL>
|
|
</OL>
|
|
|
|
@param primaryCatalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param primarySchema a schema name; "" retrieves those
|
|
without a schema
|
|
@param primaryTable the table name that exports the key
|
|
@param foreignCatalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param foreignSchema a schema name; "" retrieves those
|
|
without a schema
|
|
@param foreignTable the table name that imports the key
|
|
@return <code>ResultSet</code> - each row is a foreign key column description
|
|
@see #getImportedKeys
|
|
}
|
|
function TZOracleDatabaseMetadata.GetCrossReference(const PrimaryCatalog: string;
|
|
const PrimarySchema: string; const PrimaryTable: string; const ForeignCatalog: string;
|
|
const ForeignSchema: string; const ForeignTable: string): IZResultSet;
|
|
begin
|
|
Result := inherited GetCrossReference(PrimaryCatalog, PrimarySchema,
|
|
PrimaryTable, ForeignCatalog, ForeignSchema, ForeignTable);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of all the standard SQL types supported by
|
|
this database. They are ordered by DATA_TYPE and then by how
|
|
closely the data type maps to the corresponding JDBC SQL type.
|
|
|
|
<P>Each type description has the following columns:
|
|
<OL>
|
|
<LI><B>TYPE_NAME</B> String => Type name
|
|
<LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
|
|
<LI><B>PRECISION</B> int => maximum precision
|
|
<LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
|
|
(may be null)
|
|
<LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
|
|
(may be null)
|
|
<LI><B>CREATE_PARAMS</B> String => parameters used in creating
|
|
the type (may be null)
|
|
<LI><B>NULLABLE</B> short => can you use NULL for this type?
|
|
<UL>
|
|
<LI> typeNoNulls - does not allow NULL values
|
|
<LI> typeNullable - allows NULL values
|
|
<LI> typeNullableUnknown - nullability unknown
|
|
</UL>
|
|
<LI><B>CASE_SENSITIVE</B> Boolean=> is it case sensitive?
|
|
<LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
|
|
<UL>
|
|
<LI> typePredNone - No support
|
|
<LI> typePredChar - Only supported with WHERE .. LIKE
|
|
<LI> typePredBasic - Supported except for WHERE .. LIKE
|
|
<LI> typeSearchable - Supported for all WHERE ..
|
|
</UL>
|
|
<LI><B>UNSIGNED_ATTRIBUTE</B> Boolean => is it unsigned?
|
|
<LI><B>FIXED_PREC_SCALE</B> Boolean => can it be a money value?
|
|
<LI><B>AUTO_INCREMENT</B> Boolean => can it be used for an
|
|
auto-increment value?
|
|
<LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
|
|
(may be null)
|
|
<LI><B>MINIMUM_SCALE</B> short => minimum scale supported
|
|
<LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
|
|
<LI><B>SQL_DATA_TYPE</B> int => unused
|
|
<LI><B>SQL_DATETIME_SUB</B> int => unused
|
|
<LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
|
|
</OL>
|
|
|
|
@return <code>ResultSet</code> - each row is an SQL type description
|
|
}
|
|
function TZOracleDatabaseMetadata.GetTypeInfo: IZResultSet;
|
|
begin
|
|
Result := inherited GetTypeInfo;
|
|
end;
|
|
|
|
{**
|
|
Gets a description of a table's indices and statistics. They are
|
|
ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
|
|
|
|
<P>Each index column description has the following columns:
|
|
<OL>
|
|
<LI><B>TABLE_CAT</B> String => table catalog (may be null)
|
|
<LI><B>TABLE_SCHEM</B> String => table schema (may be null)
|
|
<LI><B>TABLE_NAME</B> String => table name
|
|
<LI><B>NON_UNIQUE</B> Boolean => Can index values be non-unique?
|
|
false when TYPE is tableIndexStatistic
|
|
<LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
|
|
null when TYPE is tableIndexStatistic
|
|
<LI><B>INDEX_NAME</B> String => index name; null when TYPE is
|
|
tableIndexStatistic
|
|
<LI><B>TYPE</B> short => index type:
|
|
<UL>
|
|
<LI> tableIndexStatistic - this identifies table statistics that are
|
|
returned in conjuction with a table's index descriptions
|
|
<LI> tableIndexClustered - this is a clustered index
|
|
<LI> tableIndexHashed - this is a hashed index
|
|
<LI> tableIndexOther - this is some other style of index
|
|
</UL>
|
|
<LI><B>ORDINAL_POSITION</B> short => column sequence number
|
|
within index; zero when TYPE is tableIndexStatistic
|
|
<LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
|
|
tableIndexStatistic
|
|
<LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
|
|
"D" => descending, may be null if sort sequence is not supported;
|
|
null when TYPE is tableIndexStatistic
|
|
<LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
|
|
this is the number of rows in the table; otherwise, it is the
|
|
number of unique values in the index.
|
|
<LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
|
|
this is the number of pages used for the table, otherwise it
|
|
is the number of pages used for the current index.
|
|
<LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
|
|
(may be null)
|
|
</OL>
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schema a schema name; "" retrieves those without a schema
|
|
@param table a table name
|
|
@param unique when true, return only indices for unique values;
|
|
when false, return indices regardless of whether unique or not
|
|
@param approximate when true, result is allowed to reflect approximate
|
|
or out of data values; when false, results are requested to be
|
|
accurate
|
|
@return <code>ResultSet</code> - each row is an index column description
|
|
}
|
|
function TZOracleDatabaseMetadata.GetIndexInfo(const Catalog: string;
|
|
const Schema: string; const Table: string; Unique: Boolean;
|
|
Approximate: Boolean): IZResultSet;
|
|
var
|
|
Key, SQL: string;
|
|
begin
|
|
Key := Format('get-index-info:%s:%s:%s:%s:%s',
|
|
[Catalog, Schema, Table, BoolToStr(Unique), BoolToStr(Approximate)]);
|
|
|
|
Result := GetResultSetFromCache(Key);
|
|
if Result = nil then
|
|
begin
|
|
Result := ConstructVirtualResultSet(IndexInfoColumnsDynArray);
|
|
|
|
SQL := 'SELECT NULL, A.OWNER, A.TABLE_NAME, A.UNIQUENESS, NULL,'
|
|
+ ' A.INDEX_NAME, 3, B.COLUMN_POSITION, B.COLUMN_NAME, B.DESCEND,'
|
|
+ ' 0, 0, NULL FROM ALL_INDEXES A, ALL_IND_COLUMNS B'
|
|
+ ' WHERE A.OWNER=B.INDEX_OWNER AND A.INDEX_NAME=B.INDEX_NAME'
|
|
+ ' AND A.TABLE_OWNER=B.TABLE_OWNER AND A.TABLE_NAME=B.TABLE_NAME';
|
|
if Schema <> '' then
|
|
SQL := SQL + ' AND A.TABLE_OWNER=''' + Schema + '''';
|
|
if Table <> '' then
|
|
SQL := SQL + ' AND A.TABLE_NAME=''' + Table + '''';
|
|
if Unique then
|
|
SQL := SQL + ' AND A.UNIQUENESS=''UNIQUE''';
|
|
SQL := SQL + ' ORDER BY A.UNIQUENESS DESC, A.INDEX_NAME, B.COLUMN_POSITION';
|
|
|
|
with GetConnection.CreateStatement.ExecuteQuery(SQL) do
|
|
begin
|
|
while Next do
|
|
begin
|
|
Result.MoveToInsertRow;
|
|
|
|
Result.UpdateNull(1);
|
|
Result.UpdateString(2, GetString(2));
|
|
Result.UpdateString(3, GetString(3));
|
|
Result.UpdateBoolean(4,
|
|
UpperCase(GetString(4)) <> 'UNIQUE');
|
|
Result.UpdateNull(5);
|
|
Result.UpdateString(6, GetString(6));
|
|
Result.UpdateInt(7, GetInt(7));
|
|
Result.UpdateInt(8, GetInt(8));
|
|
Result.UpdateString(9, GetString(9));
|
|
if GetString(10) = 'ASC' then
|
|
Result.UpdateString(10, 'A')
|
|
else Result.UpdateString(10, 'D');
|
|
Result.UpdateInt(11, GetInt(11));
|
|
Result.UpdateInt(12, GetInt(12));
|
|
Result.UpdateNull(13);
|
|
|
|
Result.InsertRow;
|
|
end;
|
|
Close;
|
|
end;
|
|
|
|
AddResultSetToCache(Key, Result);
|
|
end;
|
|
end;
|
|
|
|
{**
|
|
Does the database support the given result set type?
|
|
@param type defined in <code>java.sql.ResultSet</code>
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsResultSetType(
|
|
_Type: TZResultSetType): Boolean;
|
|
begin
|
|
Result := _Type = rtForwardOnly;
|
|
end;
|
|
|
|
{**
|
|
Does the database support the concurrency type in combination
|
|
with the given result set type?
|
|
|
|
@param type defined in <code>java.sql.ResultSet</code>
|
|
@param concurrency type defined in <code>java.sql.ResultSet</code>
|
|
@return <code>true</code> if so; <code>false</code> otherwise
|
|
}
|
|
function TZOracleDatabaseMetadata.SupportsResultSetConcurrency(
|
|
_Type: TZResultSetType; Concurrency: TZResultSetConcurrency): Boolean;
|
|
begin
|
|
Result := (_Type = rtForwardOnly) and (Concurrency = rcReadOnly);
|
|
end;
|
|
|
|
{**
|
|
Gets a description of the user-defined types defined in a particular
|
|
schema. Schema-specific UDTs may have type JAVA_OBJECT, STRUCT,
|
|
or DISTINCT.
|
|
|
|
<P>Only types matching the catalog, schema, type name and type
|
|
criteria are returned. They are ordered by DATA_TYPE, TYPE_SCHEM
|
|
and TYPE_NAME. The type name parameter may be a fully-qualified
|
|
name. In this case, the catalog and schemaPattern parameters are
|
|
ignored.
|
|
|
|
<P>Each type description has the following columns:
|
|
<OL>
|
|
<LI><B>TYPE_CAT</B> String => the type's catalog (may be null)
|
|
<LI><B>TYPE_SCHEM</B> String => type's schema (may be null)
|
|
<LI><B>TYPE_NAME</B> String => type name
|
|
<LI><B>CLASS_NAME</B> String => Java class name
|
|
<LI><B>DATA_TYPE</B> String => type value defined in java.sql.Types.
|
|
One of JAVA_OBJECT, STRUCT, or DISTINCT
|
|
<LI><B>REMARKS</B> String => explanatory comment on the type
|
|
</OL>
|
|
|
|
<P><B>Note:</B> If the driver does not support UDTs, an empty
|
|
result set is returned.
|
|
|
|
@param catalog a catalog name; "" retrieves those without a
|
|
catalog; null means drop catalog name from the selection criteria
|
|
@param schemaPattern a schema name pattern; "" retrieves those
|
|
without a schema
|
|
@param typeNamePattern a type name pattern; may be a fully-qualified name
|
|
@param types a list of user-named types to include (JAVA_OBJECT,
|
|
STRUCT, or DISTINCT); null returns all types
|
|
@return <code>ResultSet</code> - each row is a type description
|
|
}
|
|
function TZOracleDatabaseMetadata.GetUDTs(const Catalog: string;
|
|
const SchemaPattern: string; const TypeNamePattern: string;
|
|
const Types: TIntegerDynArray): IZResultSet;
|
|
begin
|
|
Result := inherited GetUDTs(Catalog, SchemaPattern, TypeNamePattern, Types);
|
|
end;
|
|
|
|
end.
|