00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Interbase Database Connectivity Classes }
00005 { }
00006 { Originally written by Sergey Merkuriev }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZDbcASAMetadata;
00055
00056 interface
00057
00058 {$I ZDbc.inc}
00059
00060 uses
00061 {$IFNDEF VER130BELOW}
00062 Types,
00063 {$ENDIF}
00064 Classes, SysUtils, ZSysUtils, ZDbcIntfs, ZDbcMetadata, ZCompatibility,
00065 ZDbcConnection, ZDbcASA;
00066
00067 type
00068
00069 {** Implements ASA Database Metadata. }
00070 TZASADatabaseMetadata = class(TZAbstractDatabaseMetadata)
00071 private
00072 FASAConnection: TZASAConnection;
00073 protected
00074 function GetStatement: IZStatement;
00075 function UncachedGetTables(const Catalog: string; const SchemaPattern: string;
00076 const TableNamePattern: string; const Types: TStringDynArray): IZResultSet; override;
00077 function UncachedGetSchemas: IZResultSet; override;
00078
00079 function UncachedGetTableTypes: IZResultSet; override;
00080 function UncachedGetColumns(const Catalog: string; const SchemaPattern: string;
00081 const TableNamePattern: string; const ColumnNamePattern: string): IZResultSet; override;
00082 function UncachedGetTablePrivileges(const Catalog: string; const SchemaPattern: string;
00083 const TableNamePattern: string): IZResultSet; override;
00084 function UncachedGetColumnPrivileges(const Catalog: string; const Schema: string;
00085 const Table: string; const ColumnNamePattern: string): IZResultSet; override;
00086 function UncachedGetPrimaryKeys(const Catalog: string; const Schema: string;
00087 const Table: string): IZResultSet; override;
00088 function UncachedGetImportedKeys(const Catalog: string; const Schema: string;
00089 const Table: string): IZResultSet; override;
00090 function UncachedGetExportedKeys(const Catalog: string; const Schema: string;
00091 const Table: string): IZResultSet; override;
00092 function UncachedGetCrossReference(const PrimaryCatalog: string; const PrimarySchema: string;
00093 const PrimaryTable: string; const ForeignCatalog: string; const ForeignSchema: string;
00094 const ForeignTable: string): IZResultSet; override;
00095 function UncachedGetIndexInfo(const Catalog: string; const Schema: string; const Table: string;
00096 Unique: Boolean; Approximate: Boolean): IZResultSet; override;
00097
00098
00099 function UncachedGetProcedures(const Catalog: string; const SchemaPattern: string;
00100 const ProcedureNamePattern: string): IZResultSet; override;
00101 function UncachedGetProcedureColumns(const Catalog: string; const SchemaPattern: string;
00102 const ProcedureNamePattern: string; const ColumnNamePattern: string):
00103 IZResultSet; override;
00104 function UncachedGetVersionColumns(const Catalog: string; const Schema: string;
00105 const Table: string): IZResultSet; override;
00106 function UncachedGetTypeInfo: IZResultSet; override;
00107 function UncachedGetUDTs(const Catalog: string; const SchemaPattern: string;
00108 const TypeNamePattern: string; const Types: TIntegerDynArray): IZResultSet; override;
00109 public
00110 constructor Create(Connection: TZAbstractConnection; Url: string; Info: TStrings);
00111 destructor Destroy; override;
00112
00113 function NullsAreSortedAtStart: Boolean; override;
00114 function GetDatabaseProductName: string; override;
00115 function GetDatabaseProductVersion: string; override;
00116 function GetDriverName: string; override;
00117 function GetDriverMajorVersion: Integer; override;
00118 function GetDriverMinorVersion: Integer; override;
00119 function UsesLocalFiles: Boolean; override;
00120 function UsesLocalFilePerTable: Boolean; override;
00121 function SupportsMixedCaseIdentifiers: Boolean; override;
00122 function StoresUpperCaseIdentifiers: Boolean; override;
00123 function StoresLowerCaseIdentifiers: Boolean; override;
00124 function StoresMixedCaseIdentifiers: Boolean; override;
00125 function SupportsMixedCaseQuotedIdentifiers: Boolean; override;
00126 function StoresUpperCaseQuotedIdentifiers: Boolean; override;
00127 function StoresLowerCaseQuotedIdentifiers: Boolean; override;
00128 function StoresMixedCaseQuotedIdentifiers: Boolean; override;
00129 function GetSQLKeywords: string; override;
00130 function GetNumericFunctions: string; override;
00131 function GetStringFunctions: string; override;
00132 function GetSystemFunctions: string; override;
00133 function GetTimeDateFunctions: string; override;
00134 function GetSearchStringEscape: string; override;
00135 function GetExtraNameCharacters: string; override;
00136
00137 function SupportsExpressionsInOrderBy: Boolean; override;
00138 function SupportsOrderByUnrelated: Boolean; override;
00139 function SupportsGroupBy: Boolean; override;
00140 function SupportsGroupByUnrelated: Boolean; override;
00141 function SupportsGroupByBeyondSelect: Boolean; override;
00142 function SupportsIntegrityEnhancementFacility: Boolean; override;
00143 function GetSchemaTerm: string; override;
00144 function GetProcedureTerm: string; override;
00145 function GetCatalogTerm: string; override;
00146 function GetCatalogSeparator: string; override;
00147 function SupportsSchemasInDataManipulation: Boolean; override;
00148 function SupportsSchemasInProcedureCalls: Boolean; override;
00149 function SupportsSchemasInTableDefinitions: Boolean; override;
00150 function SupportsSchemasInIndexDefinitions: Boolean; override;
00151 function SupportsSchemasInPrivilegeDefinitions: Boolean; override;
00152 function SupportsCatalogsInDataManipulation: Boolean; override;
00153 function SupportsCatalogsInProcedureCalls: Boolean; override;
00154 function SupportsCatalogsInTableDefinitions: Boolean; override;
00155 function SupportsCatalogsInIndexDefinitions: Boolean; override;
00156 function SupportsCatalogsInPrivilegeDefinitions: Boolean; override;
00157 function SupportsPositionedDelete: Boolean; override;
00158 function SupportsPositionedUpdate: Boolean; override;
00159 function SupportsSelectForUpdate: Boolean; override;
00160 function SupportsStoredProcedures: Boolean; override;
00161 function SupportsSubqueriesInComparisons: Boolean; override;
00162 function SupportsSubqueriesInExists: Boolean; override;
00163 function SupportsSubqueriesInIns: Boolean; override;
00164 function SupportsSubqueriesInQuantifieds: Boolean; override;
00165 function SupportsCorrelatedSubqueries: Boolean; override;
00166 function SupportsUnion: Boolean; override;
00167 function SupportsUnionAll: Boolean; override;
00168 function SupportsOpenCursorsAcrossCommit: Boolean; override;
00169 function SupportsOpenCursorsAcrossRollback: Boolean; override;
00170 function SupportsOpenStatementsAcrossCommit: Boolean; override;
00171 function SupportsOpenStatementsAcrossRollback: Boolean; override;
00172
00173 function GetMaxBinaryLiteralLength: Integer; override;
00174 function GetMaxCharLiteralLength: Integer; override;
00175 function GetMaxColumnNameLength: Integer; override;
00176 function GetMaxColumnsInGroupBy: Integer; override;
00177 function GetMaxColumnsInIndex: Integer; override;
00178 function GetMaxColumnsInOrderBy: Integer; override;
00179 function GetMaxColumnsInSelect: Integer; override;
00180 function GetMaxColumnsInTable: Integer; override;
00181 function GetMaxConnections: Integer; override;
00182 function GetMaxCursorNameLength: Integer; override;
00183 function GetMaxIndexLength: Integer; override;
00184 function GetMaxSchemaNameLength: Integer; override;
00185 function GetMaxProcedureNameLength: Integer; override;
00186 function GetMaxCatalogNameLength: Integer; override;
00187 function GetMaxRowSize: Integer; override;
00188 function DoesMaxRowSizeIncludeBlobs: Boolean; override;
00189 function GetMaxStatementLength: Integer; override;
00190 function GetMaxStatements: Integer; override;
00191 function GetMaxTableNameLength: Integer; override;
00192 function GetMaxTablesInSelect: Integer; override;
00193 function GetMaxUserNameLength: Integer; override;
00194
00195 function GetDefaultTransactionIsolation: TZTransactIsolationLevel; override;
00196 function SupportsTransactions: Boolean; override;
00197 function SupportsTransactionIsolationLevel(Level: TZTransactIsolationLevel):
00198 Boolean; override;
00199 function SupportsDataDefinitionAndDataManipulationTransactions: Boolean; override;
00200 function SupportsDataManipulationTransactionsOnly: Boolean; override;
00201 function DataDefinitionCausesTransactionCommit: Boolean; override;
00202 function DataDefinitionIgnoredInTransactions: Boolean; override;
00203
00204 function SupportsResultSetType(_Type: TZResultSetType): Boolean; override;
00205 function SupportsResultSetConcurrency(_Type: TZResultSetType;
00206 Concurrency: TZResultSetConcurrency): Boolean; override;
00207 end;
00208
00209 implementation
00210
00211 uses ZDbcASAUtils, ZDbcUtils;
00212
00213 { TZASADatabaseMetadata }
00214
00215 {**
00216 Constructs this object and assignes the main properties.
00217 @param Connection a database connection object.
00218 @param Url a database connection url string.
00219 @param Info an extra connection properties.
00220 }
00221 constructor TZASADatabaseMetadata.Create(Connection: TZAbstractConnection;
00222 Url: string; Info: TStrings);
00223 begin
00224 inherited Create(Connection, Url, Info);
00225 FASAConnection := Connection as TZASAConnection;
00226 end;
00227
00228 {**
00229 Destroys this object and cleanups the memory.
00230 }
00231 destructor TZASADatabaseMetadata.Destroy;
00232 begin
00233 inherited Destroy;
00234 end;
00235
00236
00237
00238
00239 {**
00240 Are NULL values sorted at the start regardless of sort order?
00241 @return <code>true</code> if so; <code>false</code> otherwise
00242 }
00243 function TZASADatabaseMetadata.NullsAreSortedAtStart: Boolean;
00244 begin
00245 Result := True;
00246 end;
00247
00248 {**
00249 What's the name of this database product?
00250 @return database product name
00251 }
00252 function TZASADatabaseMetadata.GetDatabaseProductName: string;
00253 begin
00254 Result := 'Sybase ASA';
00255 end;
00256
00257 {**
00258 What's the version of this database product?
00259 @return database version
00260 }
00261 function TZASADatabaseMetadata.GetDatabaseProductVersion: string;
00262 begin
00263 Result := '7.0+';
00264 end;
00265
00266 {**
00267 What's the name of this JDBC driver?
00268 @return JDBC driver name
00269 }
00270 function TZASADatabaseMetadata.GetDriverName: string;
00271 begin
00272 Result := 'Zeos Database Connectivity Driver for Sybase ASA';
00273 end;
00274
00275 {**
00276 What's this JDBC driver's major version number?
00277 @return JDBC driver major version
00278 }
00279 function TZASADatabaseMetadata.GetDriverMajorVersion: Integer;
00280 begin
00281 Result := 1;
00282 end;
00283
00284 {**
00285 What's this JDBC driver's minor version number?
00286 @return JDBC driver minor version number
00287 }
00288 function TZASADatabaseMetadata.GetDriverMinorVersion: Integer;
00289 begin
00290 Result := 0;
00291 end;
00292
00293 {**
00294 Does the database store tables in a local file?
00295 @return <code>true</code> if so; <code>false</code> otherwise
00296 }
00297 function TZASADatabaseMetadata.UsesLocalFiles: Boolean;
00298 begin
00299 Result := False;
00300 end;
00301
00302 {**
00303 Does the database use a file for each table?
00304 @return true if the database uses a local file for each table
00305 }
00306 function TZASADatabaseMetadata.UsesLocalFilePerTable: Boolean;
00307 begin
00308 Result := False;
00309 end;
00310
00311 {**
00312 Does the database treat mixed case unquoted SQL identifiers as
00313 case sensitive and as a result store them in mixed case?
00314 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return false.
00315 @return <code>true</code> if so; <code>false</code> otherwise
00316 }
00317 function TZASADatabaseMetadata.SupportsMixedCaseIdentifiers: Boolean;
00318 begin
00319 Result := False;
00320 end;
00321
00322 {**
00323 Does the database treat mixed case unquoted SQL identifiers as
00324 case insensitive and store them in upper case?
00325 @return <code>true</code> if so; <code>false</code> otherwise
00326 }
00327 function TZASADatabaseMetadata.StoresUpperCaseIdentifiers: Boolean;
00328 begin
00329 Result := False;
00330 end;
00331
00332 {**
00333 Does the database treat mixed case unquoted SQL identifiers as
00334 case insensitive and store them in lower case?
00335 @return <code>true</code> if so; <code>false</code> otherwise
00336 }
00337 function TZASADatabaseMetadata.StoresLowerCaseIdentifiers: Boolean;
00338 begin
00339 Result := False;
00340 end;
00341
00342 {**
00343 Does the database treat mixed case unquoted SQL identifiers as
00344 case insensitive and store them in mixed case?
00345 @return <code>true</code> if so; <code>false</code> otherwise
00346 }
00347 function TZASADatabaseMetadata.StoresMixedCaseIdentifiers: Boolean;
00348 begin
00349 Result := True;
00350 end;
00351
00352 {**
00353 Does the database treat mixed case quoted SQL identifiers as
00354 case sensitive and as a result store them in mixed case?
00355 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver will always return true.
00356 @return <code>true</code> if so; <code>false</code> otherwise
00357 }
00358 function TZASADatabaseMetadata.SupportsMixedCaseQuotedIdentifiers: Boolean;
00359 begin
00360 Result := False;
00361 end;
00362
00363 {**
00364 Does the database treat mixed case quoted SQL identifiers as
00365 case insensitive and store them in upper case?
00366 @return <code>true</code> if so; <code>false</code> otherwise
00367 }
00368 function TZASADatabaseMetadata.StoresUpperCaseQuotedIdentifiers: Boolean;
00369 begin
00370 Result := False;
00371 end;
00372
00373 {**
00374 Does the database treat mixed case quoted SQL identifiers as
00375 case insensitive and store them in lower case?
00376 @return <code>true</code> if so; <code>false</code> otherwise
00377 }
00378 function TZASADatabaseMetadata.StoresLowerCaseQuotedIdentifiers: Boolean;
00379 begin
00380 Result := False;
00381 end;
00382
00383 {**
00384 Does the database treat mixed case quoted SQL identifiers as
00385 case insensitive and store them in mixed case?
00386 @return <code>true</code> if so; <code>false</code> otherwise
00387 }
00388 function TZASADatabaseMetadata.StoresMixedCaseQuotedIdentifiers: Boolean;
00389 begin
00390 Result := True;
00391 end;
00392
00393 {**
00394 Gets a comma-separated list of all a database's SQL keywords
00395 that are NOT also SQL92 keywords.
00396 @return the list
00397 }
00398 function TZASADatabaseMetadata.GetSQLKeywords: string;
00399 begin
00400 Result := 'add,all,alter,and,any,as,asc,backup,begin,between,bigint,binary,'+
00401 'bit,bottom,break,by,call,capability,cascade,case,cast,char,'+
00402 'char_convert,character,check,checkpoint,close,comment,commit,'+
00403 'connect,constraint,contains,continue,convert,create,cross,cube,'+
00404 'current,cursor,date,dbspace,deallocate,dec,decimal,declare,'+
00405 'default,delete,deleting,desc,distinct,do,double,drop,dynamic,'+
00406 'else,elseif,encrypted,end,endif,escape,exception,exec,execute,'+
00407 'existing,exists,externlogin,fetch,first,float,for,foreign,'+
00408 'forward,from,full,goto,grant,group,having,holdlock,identified,'+
00409 'if,in,index,inner,inout,insensitive,insert,inserting,install,'+
00410 'instead,int,integer,integrated,into,iq,is,isolation,join,key,'+
00411 'left,like,lock,login,long,match,membership,message,mode,modify,'+
00412 'natural,new,no,noholdlock,not,notify,null,numeric,of,off,on,open,'+
00413 'option,options,or,order,others,out,outer,over,passthrough,'+
00414 'precision,prepare,primary,print,privileges,proc,procedure,'+
00415 'publication,raiserror,readtext,real,reference,references,release,'+
00416 'remote,remove,rename,reorganize,resource,restore,restrict,return'+
00417 'revoke,right,rollback,rollup,save,savepoint,schedule,scroll,'+
00418 'select,sensitive,session,set,setuser,share,smallint,some,sqlcode,'+
00419 'sqlstate,start,stop,subtrans,subtransaction,synchronize,'+
00420 'syntax_error,table,temporary,then,time,timestamp,tinyint,to,top,'+
00421 'tran,trigger,truncate,tsequal,union,unique,unknown,unsigned,'+
00422 'update,updating,user,using,validate,values,varbinary,varchar,'+
00423 'variable,varying,view,wait,waitfor,when,where,while,with,'+
00424 'with_lparen,work,writetext';
00425 end;
00426
00427 {**
00428 Gets a comma-separated list of math functions. These are the
00429 X/Open CLI math function names used in the JDBC function escape
00430 clause.
00431 @return the list
00432 }
00433 function TZASADatabaseMetadata.GetNumericFunctions: string;
00434 begin
00435 Result := 'ABS,ACOS,ASIN,ATAN,ATN2,CEILING,COS,COT,DEGREES,EXP,FLOOR,LOG,'+
00436 'LOG10,MOD,PI,POWER,RADIANS,RAND,REMAINDER,ROUND,SIGN,SIN,SQRT,'+
00437 'TAN,TRUNCATE,TRUNCNUM';
00438 end;
00439
00440 {**
00441 Gets a comma-separated list of string functions. These are the
00442 X/Open CLI string function names used in the JDBC function escape
00443 clause.
00444 @return the list
00445 }
00446 function TZASADatabaseMetadata.GetStringFunctions: string;
00447 begin
00448 Result := 'ASCII,BYTE_LENGTH,BYTE_SUBSTR,CHAR,CHARINDEX,CHAR_LENGTH,COMPARE,'+
00449 'CSCONVERT,DIFFERENCE,INSERTSTR,LCASE,LEFT,LENGTH,LOCATE,LOWER,'+
00450 'LTRIM,PATINDEX,REPEAT,REPLACE,REPLICATE,RIGHT,RTRIM,SIMILAR,'+
00451 'SORTKEY,SOUNDEX,SPACE,STR,STRING,STRTOUUID,STUFF,SUBSTRING,TRIM,'+
00452 'UCASE,UPPER,UUIDTOSTR';
00453 end;
00454
00455 {**
00456 Gets a comma-separated list of system functions. These are the
00457 X/Open CLI system function names used in the JDBC function escape
00458 clause.
00459 @return the list
00460 }
00461 function TZASADatabaseMetadata.GetSystemFunctions: string;
00462 begin
00463 Result := 'CONNECTION_PROPERTY,DATALENGTH,DB_ID,DB_NAME,DB_PROPERTY,'+
00464 'EVENT_CONDITION,EVENT_CONDITION_NAME,EVENT_PARAMETER,'+
00465 'NEXT_CONNECTION,NEXT_DATABASE,PROPERTY,PROPERTY_DESCRIPTION,'+
00466 'PROPERTY_NAME,PROPERTY_NUMBER,Col_length,Col_name,Datalength,'+
00467 'Index_col,Object_id,Object_name,Suser_id,Suser_name,Tsequal,'+
00468 'User_id,User_name,ARGN,COALESCE,ESTIMATE,ESTIMATE_SOURCE,'+
00469 'EXPERIENCE_ESTIMATE,EXPLANATION,GET_IDENTITY,GRAPHICAL_PLAN,'+
00470 'GRAPHICAL_ULPLAN,GREATER,IDENTITY,IFNULL,INDEX_ESTIMATE,ISNULL,'+
00471 'LESSER,LONG_ULPLAN,NEWID,NULLIF,NUMBER,PLAN,REWRITE,SHORT_ULPLAN,'+
00472 'SQLDIALECT,TRACEBACK,TRANSACTSQL,VAREXISTS,WATCOMSQL,TEXTPTR';
00473 end;
00474
00475 {**
00476 Gets a comma-separated list of time and date functions.
00477 @return the list
00478 }
00479 function TZASADatabaseMetadata.GetTimeDateFunctions: string;
00480 begin
00481 Result := 'DATE,DATEADD,DATEDIFF,DATEFORMAT,DATENAME,DATEPART,DATETIME,DAY,'+
00482 'DAYNAME,DAYS,DOW,GETDATE,HOUR,HOURS,MINUTE,MINUTES,MONTH,'+
00483 'MONTHNAME,MONTHS,NOW,QUARTER,SECOND,SECONDS,TODAY,WEEKS,YEARS,YMD';
00484 end;
00485
00486 {**
00487 Gets the string that can be used to escape wildcard characters.
00488 This is the string that can be used to escape '_' or '%' in
00489 the string pattern style catalog search parameters.
00490
00491 <P>The '_' character represents any single character.
00492 <P>The '%' character represents any sequence of zero or
00493 more characters.
00494
00495 @return the string used to escape wildcard characters
00496 }
00497 function TZASADatabaseMetadata.GetSearchStringEscape: string;
00498 begin
00499 Result := '\';
00500 end;
00501
00502 {**
00503 Gets all the "extra" characters that can be used in unquoted
00504 identifier names (those beyond a-z, A-Z, 0-9 and _).
00505 @return the string containing the extra characters
00506 }
00507 function TZASADatabaseMetadata.GetExtraNameCharacters: string;
00508 begin
00509 Result := '@#$';
00510 end;
00511
00512
00513
00514
00515 {**
00516 Are expressions in "ORDER BY" lists supported?
00517 @return <code>true</code> if so; <code>false</code> otherwise
00518 }
00519 function TZASADatabaseMetadata.SupportsExpressionsInOrderBy: Boolean;
00520 begin
00521 Result := True;
00522 end;
00523
00524 {**
00525 Can an "ORDER BY" clause use columns not in the SELECT statement?
00526 @return <code>true</code> if so; <code>false</code> otherwise
00527 }
00528 function TZASADatabaseMetadata.SupportsOrderByUnrelated: Boolean;
00529 begin
00530 Result := True;
00531 end;
00532
00533 {**
00534 Is some form of "GROUP BY" clause supported?
00535 @return <code>true</code> if so; <code>false</code> otherwise
00536 }
00537 function TZASADatabaseMetadata.SupportsGroupBy: Boolean;
00538 begin
00539 Result := True;
00540 end;
00541
00542 {**
00543 Can a "GROUP BY" clause use columns not in the SELECT?
00544 @return <code>true</code> if so; <code>false</code> otherwise
00545 }
00546 function TZASADatabaseMetadata.SupportsGroupByUnrelated: Boolean;
00547 begin
00548 Result := True;
00549 end;
00550
00551 {**
00552 Can a "GROUP BY" clause add columns not in the SELECT
00553 provided it specifies all the columns in the SELECT?
00554 @return <code>true</code> if so; <code>false</code> otherwise
00555 }
00556 function TZASADatabaseMetadata.SupportsGroupByBeyondSelect: Boolean;
00557 begin
00558 Result := False;
00559 end;
00560
00561 {**
00562 Is the SQL Integrity Enhancement Facility supported?
00563 @return <code>true</code> if so; <code>false</code> otherwise
00564 }
00565 function TZASADatabaseMetadata.SupportsIntegrityEnhancementFacility: Boolean;
00566 begin
00567 Result := True;
00568 end;
00569
00570 {**
00571 What's the database vendor's preferred term for "schema"?
00572 @return the vendor term
00573 }
00574 function TZASADatabaseMetadata.GetSchemaTerm: string;
00575 begin
00576 Result := 'OWNER';
00577 end;
00578
00579 {**
00580 What's the database vendor's preferred term for "procedure"?
00581 @return the vendor term
00582 }
00583 function TZASADatabaseMetadata.GetProcedureTerm: string;
00584 begin
00585 Result := 'PROCEDURE';
00586 end;
00587
00588 {**
00589 What's the database vendor's preferred term for "catalog"?
00590 @return the vendor term
00591 }
00592 function TZASADatabaseMetadata.GetCatalogTerm: string;
00593 begin
00594 Result := '';
00595 end;
00596
00597 {**
00598 What's the separator between catalog and table name?
00599 @return the separator string
00600 }
00601 function TZASADatabaseMetadata.GetCatalogSeparator: string;
00602 begin
00603 Result := '';
00604 end;
00605
00606 {**
00607 Can a schema name be used in a data manipulation statement?
00608 @return <code>true</code> if so; <code>false</code> otherwise
00609 }
00610 function TZASADatabaseMetadata.SupportsSchemasInDataManipulation: Boolean;
00611 begin
00612 Result := True;
00613 end;
00614
00615 {**
00616 Can a schema name be used in a procedure call statement?
00617 @return <code>true</code> if so; <code>false</code> otherwise
00618 }
00619 function TZASADatabaseMetadata.SupportsSchemasInProcedureCalls: Boolean;
00620 begin
00621 Result := True;
00622 end;
00623
00624 {**
00625 Can a schema name be used in a table definition statement?
00626 @return <code>true</code> if so; <code>false</code> otherwise
00627 }
00628 function TZASADatabaseMetadata.SupportsSchemasInTableDefinitions: Boolean;
00629 begin
00630 Result := True;
00631 end;
00632
00633 {**
00634 Can a schema name be used in an index definition statement?
00635 @return <code>true</code> if so; <code>false</code> otherwise
00636 }
00637 function TZASADatabaseMetadata.SupportsSchemasInIndexDefinitions: Boolean;
00638 begin
00639 Result := False;
00640 end;
00641
00642 {**
00643 Can a schema name be used in a privilege definition statement?
00644 @return <code>true</code> if so; <code>false</code> otherwise
00645 }
00646 function TZASADatabaseMetadata.SupportsSchemasInPrivilegeDefinitions: Boolean;
00647 begin
00648 Result := False;
00649 end;
00650
00651 {**
00652 Can a catalog name be used in a data manipulation statement?
00653 @return <code>true</code> if so; <code>false</code> otherwise
00654 }
00655 function TZASADatabaseMetadata.SupportsCatalogsInDataManipulation: Boolean;
00656 begin
00657 Result := False;
00658 end;
00659
00660 {**
00661 Can a catalog name be used in a procedure call statement?
00662 @return <code>true</code> if so; <code>false</code> otherwise
00663 }
00664 function TZASADatabaseMetadata.SupportsCatalogsInProcedureCalls: Boolean;
00665 begin
00666 Result := False;
00667 end;
00668
00669 {**
00670 Can a catalog name be used in a table definition statement?
00671 @return <code>true</code> if so; <code>false</code> otherwise
00672 }
00673 function TZASADatabaseMetadata.SupportsCatalogsInTableDefinitions: Boolean;
00674 begin
00675 Result := False;
00676 end;
00677
00678 {**
00679 Can a catalog name be used in an index definition statement?
00680 @return <code>true</code> if so; <code>false</code> otherwise
00681 }
00682 function TZASADatabaseMetadata.SupportsCatalogsInIndexDefinitions: Boolean;
00683 begin
00684 Result := False;
00685 end;
00686
00687 {**
00688 Can a catalog name be used in a privilege definition statement?
00689 @return <code>true</code> if so; <code>false</code> otherwise
00690 }
00691 function TZASADatabaseMetadata.SupportsCatalogsInPrivilegeDefinitions: Boolean;
00692 begin
00693 Result := False;
00694 end;
00695
00696 {**
00697 Is positioned DELETE supported?
00698 @return <code>true</code> if so; <code>false</code> otherwise
00699 }
00700 function TZASADatabaseMetadata.SupportsPositionedDelete: Boolean;
00701 begin
00702 Result := True;
00703 end;
00704
00705 {**
00706 Is positioned UPDATE supported?
00707 @return <code>true</code> if so; <code>false</code> otherwise
00708 }
00709 function TZASADatabaseMetadata.SupportsPositionedUpdate: Boolean;
00710 begin
00711 Result := True;
00712 end;
00713
00714 {**
00715 Is SELECT for UPDATE supported?
00716 @return <code>true</code> if so; <code>false</code> otherwise
00717 }
00718 function TZASADatabaseMetadata.SupportsSelectForUpdate: Boolean;
00719 begin
00720 Result := True;
00721 end;
00722
00723 {**
00724 Are stored procedure calls using the stored procedure escape
00725 syntax supported?
00726 @return <code>true</code> if so; <code>false</code> otherwise
00727 }
00728 function TZASADatabaseMetadata.SupportsStoredProcedures: Boolean;
00729 begin
00730 Result := True;
00731 end;
00732
00733 {**
00734 Are subqueries in comparison expressions supported?
00735 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
00736 @return <code>true</code> if so; <code>false</code> otherwise
00737 }
00738 function TZASADatabaseMetadata.SupportsSubqueriesInComparisons: Boolean;
00739 begin
00740 Result := True;
00741 end;
00742
00743 {**
00744 Are subqueries in 'exists' expressions supported?
00745 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
00746 @return <code>true</code> if so; <code>false</code> otherwise
00747 }
00748 function TZASADatabaseMetadata.SupportsSubqueriesInExists: Boolean;
00749 begin
00750 Result := True;
00751 end;
00752
00753 {**
00754 Are subqueries in 'in' statements supported?
00755 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
00756 @return <code>true</code> if so; <code>false</code> otherwise
00757 }
00758 function TZASADatabaseMetadata.SupportsSubqueriesInIns: Boolean;
00759 begin
00760 Result := True;
00761 end;
00762
00763 {**
00764 Are subqueries in quantified expressions supported?
00765 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
00766 @return <code>true</code> if so; <code>false</code> otherwise
00767 }
00768 function TZASADatabaseMetadata.SupportsSubqueriesInQuantifieds: Boolean;
00769 begin
00770 Result := True;
00771 end;
00772
00773 {**
00774 Are correlated subqueries supported?
00775 A JDBC Compliant<sup><font size=-2>TM</font></sup> driver always returns true.
00776 @return <code>true</code> if so; <code>false</code> otherwise
00777 }
00778 function TZASADatabaseMetadata.SupportsCorrelatedSubqueries: Boolean;
00779 begin
00780 Result := True;
00781 end;
00782
00783 {**
00784 Is SQL UNION supported?
00785 @return <code>true</code> if so; <code>false</code> otherwise
00786 }
00787 function TZASADatabaseMetadata.SupportsUnion: Boolean;
00788 begin
00789 Result := True;
00790 end;
00791
00792 {**
00793 Is SQL UNION ALL supported?
00794 @return <code>true</code> if so; <code>false</code> otherwise
00795 }
00796 function TZASADatabaseMetadata.SupportsUnionAll: Boolean;
00797 begin
00798 Result := True;
00799 end;
00800
00801 {**
00802 Can cursors remain open across commits?
00803 @return <code>true</code> if cursors always remain open;
00804 <code>false</code> if they might not remain open
00805 }
00806 function TZASADatabaseMetadata.SupportsOpenCursorsAcrossCommit: Boolean;
00807 begin
00808 Result := True;
00809 end;
00810
00811 {**
00812 Can cursors remain open across rollbacks?
00813 @return <code>true</code> if cursors always remain open;
00814 <code>false</code> if they might not remain open
00815 }
00816 function TZASADatabaseMetadata.SupportsOpenCursorsAcrossRollback: Boolean;
00817 begin
00818 Result := True;
00819 end;
00820
00821 {**
00822 Can statements remain open across commits?
00823 @return <code>true</code> if statements always remain open;
00824 <code>false</code> if they might not remain open
00825 }
00826 function TZASADatabaseMetadata.SupportsOpenStatementsAcrossCommit: Boolean;
00827 begin
00828 Result := True;
00829 end;
00830
00831 {**
00832 Can statements remain open across rollbacks?
00833 @return <code>true</code> if statements always remain open;
00834 <code>false</code> if they might not remain open
00835 }
00836 function TZASADatabaseMetadata.SupportsOpenStatementsAcrossRollback: Boolean;
00837 begin
00838 Result := True;
00839 end;
00840
00841 //----------------------------------------------------------------------
00842 // The following group of methods exposes various limitations
00843 // based on the target database with the current driver.
00844 // Unless otherwise specified, a result of zero means there is no
00845 // limit, or the limit is not known.
00846
00847 {**
00848 How many hex characters can you have in an inline binary literal?
00849 @return max binary literal length in hex characters;
00850 a result of zero means that there is no limit or the limit is not known
00851 }
00852 function TZASADatabaseMetadata.GetMaxBinaryLiteralLength: Integer;
00853 begin
00854 Result := 0;
00855 end;
00856
00857 {**
00858 What's the max length for a character literal?
00859 @return max literal length;
00860 a result of zero means that there is no limit or the limit is not known
00861 }
00862 function TZASADatabaseMetadata.GetMaxCharLiteralLength: Integer;
00863 begin
00864 Result := 32768;
00865 end;
00866
00867 {**
00868 What's the limit on column name length?
00869 @return max column name length;
00870 a result of zero means that there is no limit or the limit is not known
00871 }
00872 function TZASADatabaseMetadata.GetMaxColumnNameLength: Integer;
00873 begin
00874 Result := 128;
00875 end;
00876
00877 {**
00878 What's the maximum number of columns in a "GROUP BY" clause?
00879 @return max number of columns;
00880 a result of zero means that there is no limit or the limit is not known
00881 }
00882 function TZASADatabaseMetadata.GetMaxColumnsInGroupBy: Integer;
00883 begin
00884 Result := 0;
00885 end;
00886
00887 {**
00888 What's the maximum number of columns allowed in an index?
00889 @return max number of columns;
00890 a result of zero means that there is no limit or the limit is not known
00891 }
00892 function TZASADatabaseMetadata.GetMaxColumnsInIndex: Integer;
00893 begin
00894 Result := 1000000;
00895 end;
00896
00897 {**
00898 What's the maximum number of columns in an "ORDER BY" clause?
00899 @return max number of columns;
00900 a result of zero means that there is no limit or the limit is not known
00901 }
00902 function TZASADatabaseMetadata.GetMaxColumnsInOrderBy: Integer;
00903 begin
00904 Result := 1000000;
00905 end;
00906
00907 {**
00908 What's the maximum number of columns in a "SELECT" list?
00909 @return max number of columns;
00910 a result of zero means that there is no limit or the limit is not known
00911 }
00912 function TZASADatabaseMetadata.GetMaxColumnsInSelect: Integer;
00913 begin
00914 Result := 1000000;
00915 end;
00916
00917 {**
00918 What's the maximum number of columns in a table?
00919 @return max number of columns;
00920 a result of zero means that there is no limit or the limit is not known
00921 }
00922 function TZASADatabaseMetadata.GetMaxColumnsInTable: Integer;
00923 begin
00924 Result := 1000000;
00925 end;
00926
00927 {**
00928 How many active connections can we have at a time to this database?
00929 @return max number of active connections;
00930 a result of zero means that there is no limit or the limit is not known
00931 }
00932 function TZASADatabaseMetadata.GetMaxConnections: Integer;
00933 begin
00934 Result := 0;
00935 end;
00936
00937 {**
00938 What's the maximum cursor name length?
00939 @return max cursor name length in bytes;
00940 a result of zero means that there is no limit or the limit is not known
00941 }
00942 function TZASADatabaseMetadata.GetMaxCursorNameLength: Integer;
00943 begin
00944 Result := 128;
00945 end;
00946
00947 {**
00948 Retrieves the maximum number of bytes for an index, including all
00949 of the parts of the index.
00950 @return max index length in bytes, which includes the composite of all
00951 the constituent parts of the index;
00952 a result of zero means that there is no limit or the limit is not known
00953 }
00954 function TZASADatabaseMetadata.GetMaxIndexLength: Integer;
00955 begin
00956 Result := 0;
00957 end;
00958
00959 {**
00960 What's the maximum length allowed for a schema name?
00961 @return max name length in bytes;
00962 a result of zero means that there is no limit or the limit is not known
00963 }
00964 function TZASADatabaseMetadata.GetMaxSchemaNameLength: Integer;
00965 begin
00966 Result := 128;
00967 end;
00968
00969 {**
00970 What's the maximum length of a procedure name?
00971 @return max name length in bytes;
00972 a result of zero means that there is no limit or the limit is not known
00973 }
00974 function TZASADatabaseMetadata.GetMaxProcedureNameLength: Integer;
00975 begin
00976 Result := 128;
00977 end;
00978
00979 {**
00980 What's the maximum length of a catalog name?
00981 @return max name length in bytes;
00982 a result of zero means that there is no limit or the limit is not known
00983 }
00984 function TZASADatabaseMetadata.GetMaxCatalogNameLength: Integer;
00985 begin
00986 Result := 0;
00987 end;
00988
00989 {**
00990 What's the maximum length of a single row?
00991 @return max row size in bytes;
00992 a result of zero means that there is no limit or the limit is not known
00993 }
00994 function TZASADatabaseMetadata.GetMaxRowSize: Integer;
00995 begin
00996 Result := 0;
00997 end;
00998
00999 {**
01000 Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY
01001 blobs?
01002 @return <code>true</code> if so; <code>false</code> otherwise
01003 }
01004 function TZASADatabaseMetadata.DoesMaxRowSizeIncludeBlobs: Boolean;
01005 begin
01006 Result := False;
01007 end;
01008
01009 {**
01010 What's the maximum length of an SQL statement?
01011 @return max length in bytes;
01012 a result of zero means that there is no limit or the limit is not known
01013 }
01014 function TZASADatabaseMetadata.GetMaxStatementLength: Integer;
01015 begin
01016 Result := 0;
01017 end;
01018
01019 {**
01020 How many active statements can we have open at one time to this
01021 database?
01022 @return the maximum number of statements that can be open at one time;
01023 a result of zero means that there is no limit or the limit is not known
01024 }
01025 function TZASADatabaseMetadata.GetMaxStatements: Integer;
01026 begin
01027 Result := 0;
01028 end;
01029
01030 {**
01031 What's the maximum length of a table name?
01032 @return max name length in bytes;
01033 a result of zero means that there is no limit or the limit is not known
01034 }
01035 function TZASADatabaseMetadata.GetMaxTableNameLength: Integer;
01036 begin
01037 Result := 128;
01038 end;
01039
01040 {**
01041 What's the maximum number of tables in a SELECT statement?
01042 @return the maximum number of tables allowed in a SELECT statement;
01043 a result of zero means that there is no limit or the limit is not known
01044 }
01045 function TZASADatabaseMetadata.GetMaxTablesInSelect: Integer;
01046 begin
01047 Result := 0;
01048 end;
01049
01050 {**
01051 What's the maximum length of a user name?
01052 @return max user name length in bytes;
01053 a result of zero means that there is no limit or the limit is not known
01054 }
01055 function TZASADatabaseMetadata.GetMaxUserNameLength: Integer;
01056 begin
01057 Result := 30;
01058 end;
01059
01060 //----------------------------------------------------------------------
01061
01062 {**
01063 What's the database's default transaction isolation level? The
01064 values are defined in <code>java.sql.Connection</code>.
01065 @return the default isolation level
01066 @see Connection
01067 }
01068 function TZASADatabaseMetadata.GetDefaultTransactionIsolation:
01069 TZTransactIsolationLevel;
01070 begin
01071 Result := tiReadUncommitted;
01072 end;
01073
01074 {**
01075 Are transactions supported? If not, invoking the method
01076 <code>commit</code> is a noop and the isolation level is TRANSACTION_NONE.
01077 @return <code>true</code> if transactions are supported; <code>false</code> otherwise
01078 }
01079 function TZASADatabaseMetadata.SupportsTransactions: Boolean;
01080 begin
01081 Result := True;
01082 end;
01083
01084 {**
01085 Does this database support the given transaction isolation level?
01086 @param level the values are defined in <code>java.sql.Connection</code>
01087 @return <code>true</code> if so; <code>false</code> otherwise
01088 @see Connection
01089 }
01090 function TZASADatabaseMetadata.SupportsTransactionIsolationLevel(
01091 Level: TZTransactIsolationLevel): Boolean;
01092 begin
01093 Result := True;
01094 end;
01095
01096 {**
01097 Are both data definition and data manipulation statements
01098 within a transaction supported?
01099 @return <code>true</code> if so; <code>false</code> otherwise
01100 }
01101 function TZASADatabaseMetadata.
01102 SupportsDataDefinitionAndDataManipulationTransactions: Boolean;
01103 begin
01104 Result := True;
01105 end;
01106
01107 {**
01108 Are only data manipulation statements within a transaction
01109 supported?
01110 @return <code>true</code> if so; <code>false</code> otherwise
01111 }
01112 function TZASADatabaseMetadata.
01113 SupportsDataManipulationTransactionsOnly: Boolean;
01114 begin
01115 Result := False;
01116 end;
01117
01118 {**
01119 Does a data definition statement within a transaction force the
01120 transaction to commit?
01121 @return <code>true</code> if so; <code>false</code> otherwise
01122 }
01123 function TZASADatabaseMetadata.DataDefinitionCausesTransactionCommit: Boolean;
01124 begin
01125 Result := True;
01126 end;
01127
01128 {**
01129 Is a data definition statement within a transaction ignored?
01130 @return <code>true</code> if so; <code>false</code> otherwise
01131 }
01132 function TZASADatabaseMetadata.DataDefinitionIgnoredInTransactions: Boolean;
01133 begin
01134 Result := False;
01135 end;
01136
01137 {**
01138 Gets a description of the stored procedures available in a
01139 catalog.
01140
01141 <P>Only procedure descriptions matching the schema and
01142 procedure name criteria are returned. They are ordered by
01143 PROCEDURE_SCHEM, and PROCEDURE_NAME.
01144
01145 <P>Each procedure description has the the following columns:
01146 <OL>
01147 <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
01148 <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
01149 <LI><B>PROCEDURE_NAME</B> String => procedure name
01150 <LI> reserved for future use
01151 <LI> reserved for future use
01152 <LI> reserved for future use
01153 <LI><B>REMARKS</B> String => explanatory comment on the procedure
01154 <LI><B>PROCEDURE_TYPE</B> short => kind of procedure:
01155 <UL>
01156 <LI> procedureResultUnknown - May return a result
01157 <LI> procedureNoResult - Does not return a result
01158 <LI> procedureReturnsResult - Returns a result
01159 </UL>
01160 </OL>
01161
01162 @param catalog a catalog name; "" retrieves those without a
01163 catalog; null means drop catalog name from the selection criteria
01164 @param schemaPattern a schema name pattern; "" retrieves those
01165 without a schema
01166 @param procedureNamePattern a procedure name pattern
01167 @return <code>ResultSet</code> - each row is a procedure description
01168 @see #getSearchStringEscape
01169 }
01170 function TZASADatabaseMetadata.UncachedGetProcedures(const Catalog: string;
01171 const SchemaPattern: string; const ProcedureNamePattern: string): IZResultSet;
01172 begin
01173 Result := ConstructVirtualResultSet(ProceduresColumnsDynArray);
01174
01175 with GetStatement.ExecuteQuery(
01176 Format('exec sp_jdbc_stored_procedures %s, %s, %s',
01177 [AQSNull(Catalog), AQSNull(SchemaPattern), AQSNull(ProcedureNamePattern)])) do
01178 begin
01179 while Next do
01180 begin
01181 Result.MoveToInsertRow;
01182 Result.UpdateStringByName('PROCEDURE_CAT',
01183 '');
01184 Result.UpdateStringByName('PROCEDURE_SCHEM',
01185 GetStringByName('PROCEDURE_SCHEM'));
01186 Result.UpdateStringByName('PROCEDURE_NAME',
01187 GetStringByName('PROCEDURE_NAME'));
01188 Result.UpdateStringByName('REMARKS',
01189 GetStringByName('REMARKS'));
01190 Result.UpdateShortByName('PROCEDURE_TYPE',
01191 GetShortByName('PROCEDURE_TYPE'));
01192 Result.InsertRow;
01193 end;
01194 Close;
01195 end;
01196 end;
01197
01198 {**
01199 Gets a description of a catalog's stored procedure parameters
01200 and result columns.
01201
01202 <P>Only descriptions matching the schema, procedure and
01203 parameter name criteria are returned. They are ordered by
01204 PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value,
01205 if any, is first. Next are the parameter descriptions in call
01206 order. The column descriptions follow in column number order.
01207
01208 <P>Each row in the <code>ResultSet</code> is a parameter description or
01209 column description with the following fields:
01210 <OL>
01211 <LI><B>PROCEDURE_CAT</B> String => procedure catalog (may be null)
01212 <LI><B>PROCEDURE_SCHEM</B> String => procedure schema (may be null)
01213 <LI><B>PROCEDURE_NAME</B> String => procedure name
01214 <LI><B>COLUMN_NAME</B> String => column/parameter name
01215 <LI><B>COLUMN_TYPE</B> Short => kind of column/parameter:
01216 <UL>
01217 <LI> procedureColumnUnknown - nobody knows
01218 <LI> procedureColumnIn - IN parameter
01219 <LI> procedureColumnInOut - INOUT parameter
01220 <LI> procedureColumnOut - OUT parameter
01221 <LI> procedureColumnReturn - procedure return value
01222 <LI> procedureColumnResult - result column in <code>ResultSet</code>
01223 </UL>
01224 <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
01225 <LI><B>TYPE_NAME</B> String => SQL type name, for a UDT type the
01226 type name is fully qualified
01227 <LI><B>PRECISION</B> int => precision
01228 <LI><B>LENGTH</B> int => length in bytes of data
01229 <LI><B>SCALE</B> short => scale
01230 <LI><B>RADIX</B> short => radix
01231 <LI><B>NULLABLE</B> short => can it contain NULL?
01232 <UL>
01233 <LI> procedureNoNulls - does not allow NULL values
01234 <LI> procedureNullable - allows NULL values
01235 <LI> procedureNullableUnknown - nullability unknown
01236 </UL>
01237 <LI><B>REMARKS</B> String => comment describing parameter/column
01238 </OL>
01239
01240 <P><B>Note:</B> Some databases may not return the column
01241 descriptions for a procedure. Additional columns beyond
01242 REMARKS can be defined by the database.
01243
01244 @param catalog a catalog name; "" retrieves those without a
01245 catalog; null means drop catalog name from the selection criteria
01246 @param schemaPattern a schema name pattern; "" retrieves those
01247 without a schema
01248 @param procedureNamePattern a procedure name pattern
01249 @param columnNamePattern a column name pattern
01250 @return <code>ResultSet</code> - each row describes a stored procedure parameter or
01251 column
01252 @see #getSearchStringEscape
01253 }
01254 function TZASADatabaseMetadata.UncachedGetProcedureColumns(const Catalog: string;
01255 const SchemaPattern: string; const ProcedureNamePattern: string;
01256 const ColumnNamePattern: string): IZResultSet;
01257 begin
01258 Result := ConstructVirtualResultSet(ProceduresColColumnsDynArray);
01259
01260 with GetStatement.ExecuteQuery(
01261 Format('exec sp_jdbc_getprocedurecolumns %s, %s, %s, %s',
01262 [AQSNull(Catalog), AQSNull(SchemaPattern), AQSNull(ProcedureNamePattern),
01263 AQSNull(ColumnNamePattern)])) do
01264 begin
01265 while Next do
01266 begin
01267 Result.MoveToInsertRow;
01268 Result.UpdateStringByName('PROCEDURE_CAT',
01269 '');
01270 Result.UpdateStringByName('PROCEDURE_SCHEM',
01271 GetStringByName('PROCEDURE_SCHEM'));
01272 Result.UpdateStringByName('PROCEDURE_NAME',
01273 GetStringByName('PROCEDURE_NAME'));
01274 Result.UpdateStringByName('COLUMN_NAME',
01275 GetStringByName('COLUMN_NAME'));
01276 case GetShortByName('COLUMN_TYPE') of
01277 1: Result.UpdateShortByName('COLUMN_TYPE', 1);
01278 2: Result.UpdateShortByName('COLUMN_TYPE', 3);
01279 3: Result.UpdateShortByName('COLUMN_TYPE', 2);
01280 5: Result.UpdateShortByName('COLUMN_TYPE', 4);
01281 else
01282 Result.UpdateShortByName('COLUMN_TYPE', 0);
01283 end;
01284 Result.UpdateShortByName('DATA_TYPE',
01285 Ord(ConvertASAJDBCToSqlType(GetShortByName('DATA_TYPE'))));
01286 Result.UpdateStringByName('TYPE_NAME',
01287 GetStringByName('TYPE_NAME'));
01288 Result.UpdateIntByName('PRECISION',
01289 GetIntByName('PRECISION'));
01290 Result.UpdateIntByName('LENGTH',
01291 GetIntByName('LENGTH'));
01292 Result.UpdateShortByName('SCALE',
01293 GetShortByName('SCALE'));
01294 Result.UpdateShortByName('RADIX',
01295 GetShortByName('RADIX'));
01296 Result.UpdateShortByName('NULLABLE',
01297 GetShortByName('NULLABLE'));
01298 Result.UpdateStringByName('REMARKS',
01299 GetStringByName('REMARKS'));
01300 Result.InsertRow;
01301 end;
01302 Close;
01303 end;
01304 end;
01305
01306 {**
01307 Gets a description of tables available in a catalog.
01308
01309 <P>Only table descriptions matching the catalog, schema, table
01310 name and type criteria are returned. They are ordered by
01311 TABLE_TYPE, TABLE_SCHEM and TABLE_NAME.
01312
01313 <P>Each table description has the following columns:
01314 <OL>
01315 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
01316 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
01317 <LI><B>TABLE_NAME</B> String => table name
01318 <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
01319 "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
01320 "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
01321 <LI><B>REMARKS</B> String => explanatory comment on the table
01322 </OL>
01323
01324 <P><B>Note:</B> Some databases may not return information for
01325 all tables.
01326
01327 @param catalog a catalog name; "" retrieves those without a
01328 catalog; null means drop catalog name from the selection criteria
01329 @param schemaPattern a schema name pattern; "" retrieves those
01330 without a schema
01331 @param tableNamePattern a table name pattern
01332 @param types a list of table types to include; null returns all types
01333 @return <code>ResultSet</code> - each row is a table description
01334 @see #getSearchStringEscape
01335 }
01336 function TZASADatabaseMetadata.UncachedGetTables(const Catalog: string;
01337 const SchemaPattern: string; const TableNamePattern: string;
01338 const Types: TStringDynArray): IZResultSet;
01339 var
01340 I: Integer;
01341 TableTypes: string;
01342 begin
01343 Result := ConstructVirtualResultSet(TableColumnsDynArray);
01344
01345 TableTypes := '';
01346 for I := 0 to Length(Types) - 1 do
01347 begin
01348 if TableTypes <> '' then
01349 TableTypes := TableTypes + ',';
01350 TableTypes := TableTypes + AnsiQuotedStr(Types[I], '''');
01351 end;
01352
01353 with GetStatement.ExecuteQuery(
01354 Format('exec sp_jdbc_tables %s, %s, %s, %s',
01355 [AQSNull(TableNamePattern), AQSNull(SchemaPattern), AQSNull(Catalog),
01356 AQSNull(TableTypes, '"')])) do
01357 begin
01358 while Next do
01359 begin
01360 Result.MoveToInsertRow;
01361 Result.UpdateStringByName('TABLE_CAT',
01362 '');
01363 Result.UpdateStringByName('TABLE_SCHEM',
01364 GetStringByName('TABLE_SCHEM'));
01365 Result.UpdateStringByName('TABLE_NAME',
01366 GetStringByName('TABLE_NAME'));
01367 Result.UpdateStringByName('TABLE_TYPE',
01368 GetStringByName('TABLE_TYPE'));
01369 Result.UpdateStringByName('REMARKS',
01370 GetStringByName('REMARKS'));
01371 Result.InsertRow;
01372 end;
01373 Close;
01374 end;
01375 end;
01376
01377 {**
01378 Gets the schema names available in this database. The results
01379 are ordered by schema name.
01380
01381 <P>The schema column is:
01382 <OL>
01383 <LI><B>TABLE_SCHEM</B> String => schema name
01384 </OL>
01385
01386 @return <code>ResultSet</code> - each row has a single String column that is a
01387 schema name
01388 }
01389 function TZASADatabaseMetadata.UncachedGetSchemas: IZResultSet;
01390 begin
01391 Result := ConstructVirtualResultSet(SchemaColumnsDynArray);
01392 with GetStatement.ExecuteQuery('exec sp_jdbc_getschemas') do
01393 begin
01394 while Next do
01395 begin
01396 Result.MoveToInsertRow;
01397 Result.UpdateStringByName('TABLE_SCHEM',
01398 GetStringByName('TABLE_SCHEM'));
01399 Result.InsertRow;
01400 end;
01401 Close;
01402 end;
01403 end;
01404
01405 {**
01406 Gets the table types available in this database. The results
01407 are ordered by table type.
01408
01409 <P>The table type is:
01410 <OL>
01411 <LI><B>TABLE_TYPE</B> String => table type. Typical types are "TABLE",
01412 "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY",
01413 "LOCAL TEMPORARY", "ALIAS", "SYNONYM".
01414 </OL>
01415
01416 @return <code>ResultSet</code> - each row has a single String column that is a
01417 table type
01418 }
01419 function TZASADatabaseMetadata.UncachedGetTableTypes: IZResultSet;
01420 const
01421 TablesTypes: array [0..4] of string = ( 'TABLE', 'BASE', 'SYSTEM', 'VIEW',
01422 'GLOBAL TEMPORARY');
01423 var
01424 I: Integer;
01425 begin
01426 Result := ConstructVirtualResultSet(TableTypeColumnsDynArray);
01427 for I := 0 to 4 do
01428 begin
01429 Result.MoveToInsertRow;
01430 Result.UpdateString(1, TablesTypes[I]);
01431 Result.InsertRow;
01432 end;
01433 end;
01434
01435 {**
01436 Gets a description of table columns available in
01437 the specified catalog.
01438
01439 <P>Only column descriptions matching the catalog, schema, table
01440 and column name criteria are returned. They are ordered by
01441 TABLE_SCHEM, TABLE_NAME and ORDINAL_POSITION.
01442
01443 <P>Each column description has the following columns:
01444 <OL>
01445 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
01446 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
01447 <LI><B>TABLE_NAME</B> String => table name
01448 <LI><B>COLUMN_NAME</B> String => column name
01449 <LI><B>DATA_TYPE</B> short => SQL type from java.sql.Types
01450 <LI><B>TYPE_NAME</B> String => Data source dependent type name,
01451 for a UDT the type name is fully qualified
01452 <LI><B>COLUMN_SIZE</B> int => column size. For char or date
01453 types this is the maximum number of characters, for numeric or
01454 decimal types this is precision.
01455 <LI><B>BUFFER_LENGTH</B> is not used.
01456 <LI><B>DECIMAL_DIGITS</B> int => the number of fractional digits
01457 <LI><B>NUM_PREC_RADIX</B> int => Radix (typically either 10 or 2)
01458 <LI><B>NULLABLE</B> int => is NULL allowed?
01459 <UL>
01460 <LI> columnNoNulls - might not allow NULL values
01461 <LI> columnNullable - definitely allows NULL values
01462 <LI> columnNullableUnknown - nullability unknown
01463 </UL>
01464 <LI><B>REMARKS</B> String => comment describing column (may be null)
01465 <LI><B>COLUMN_DEF</B> String => default value (may be null)
01466 <LI><B>SQL_DATA_TYPE</B> int => unused
01467 <LI><B>SQL_DATETIME_SUB</B> int => unused
01468 <LI><B>CHAR_OCTET_LENGTH</B> int => for char types the
01469 maximum number of bytes in the column
01470 <LI><B>ORDINAL_POSITION</B> int => index of column in table
01471 (starting at 1)
01472 <LI><B>IS_NULLABLE</B> String => "NO" means column definitely
01473 does not allow NULL values; "YES" means the column might
01474 allow NULL values. An empty string means nobody knows.
01475 </OL>
01476
01477 @param catalog a catalog name; "" retrieves those without a
01478 catalog; null means drop catalog name from the selection criteria
01479 @param schemaPattern a schema name pattern; "" retrieves those
01480 without a schema
01481 @param tableNamePattern a table name pattern
01482 @param columnNamePattern a column name pattern
01483 @return <code>ResultSet</code> - each row is a column description
01484 @see #getSearchStringEscape
01485 }
01486 function TZASADatabaseMetadata.UncachedGetColumns(const Catalog: string;
01487 const SchemaPattern: string; const TableNamePattern: string;
01488 const ColumnNamePattern: string): IZResultSet;
01489 begin
01490 Result := ConstructVirtualResultSet(TableColColumnsDynArray);
01491
01492 with GetStatement.ExecuteQuery(
01493 Format('exec sp_jdbc_columns %s, %s, %s, %s',
01494 [AQSNull(TableNamePattern), AQSNull(SchemaPattern), AQSNull(Catalog),
01495 AQSNull(ColumnNamePattern)])) do
01496 begin
01497 while Next do
01498 begin
01499 Result.MoveToInsertRow;
01500 Result.UpdateStringByName('TABLE_CAT',
01501 '');
01502 Result.UpdateStringByName('TABLE_SCHEM',
01503 GetStringByName('TABLE_SCHEM'));
01504 Result.UpdateStringByName('TABLE_NAME',
01505 GetStringByName('TABLE_NAME'));
01506 Result.UpdateStringByName('COLUMN_NAME',
01507 GetStringByName('COLUMN_NAME'));
01508 //The value in the resultset will be used
01509 // Result.UpdateShortByName('DATA_TYPE',
01510 // Ord(ConvertASAJDBCToSqlType(GetShortByName('DATA_TYPE'))));
01511 Result.UpdateStringByName('TYPE_NAME',
01512 GetStringByName('TYPE_NAME'));
01513 Result.UpdateIntByName('COLUMN_SIZE',
01514 GetIntByName('COLUMN_SIZE'));
01515 Result.UpdateIntByName('BUFFER_LENGTH',
01516 GetIntByName('BUFFER_LENGTH'));
01517 Result.UpdateIntByName('DECIMAL_DIGITS',
01518 GetIntByName('DECIMAL_DIGITS'));
01519 Result.UpdateIntByName('NUM_PREC_RADIX',
01520 GetShortByName('NUM_PREC_RADIX'));
01521 Result.UpdateStringByName('REMARKS',
01522 GetStringByName('REMARKS'));
01523 Result.UpdateStringByName('COLUMN_DEF',
01524 GetStringByName('COLUMN_DEF'));
01525 Result.UpdateShortByName('SQL_DATA_TYPE',
01526 GetShortByName('SQL_DATA_TYPE'));
01527 Result.UpdateShortByName('SQL_DATETIME_SUB',
01528 GetShortByName('SQL_DATETIME_SUB'));
01529 Result.UpdateIntByName('CHAR_OCTET_LENGTH',
01530 GetIntByName('CHAR_OCTET_LENGTH'));
01531 Result.UpdateIntByName('ORDINAL_POSITION',
01532 GetIntByName('ORDINAL_POSITION'));
01533
01534 Result.UpdateBooleanByName('AUTO_INCREMENT',
01535 CompareText( Trim( GetStringByName('COLUMN_DEF')), 'autoincrement') = 0 );
01536 Result.UpdateNullByName('CASE_SENSITIVE');
01537 Result.UpdateBooleanByName('SEARCHABLE', False);
01538 Result.UpdateStringByName('IS_NULLABLE', GetStringByName( 'IS_NULLABLE'));
01539 Result.UpdateShortByName('NULLABLE', GetShortByName( 'NULLABLE'));
01540 Result.UpdateBooleanByName('WRITABLE', True);
01541 Result.UpdateBooleanByName('DEFINITELYWRITABLE', True);
01542 Result.UpdateBooleanByName('READONLY', False);
01543 Result.InsertRow;
01544 end;
01545 Close;
01546 end;
01547 Result.First;
01548 with GetStatement.ExecuteQuery(
01549 Format('select c.column_id,c.nulls '+
01550 'from SYS.SYSCOLUMN as c join SYS.SYSTABLE as t on c.table_id=t.table_id '+
01551 'where t.table_name like %s escape ''\'' and '+
01552 'USER_NAME(t.creator) like %s escape ''\'' and '+
01553 'c.column_name like %s escape ''\'' and c.column_type=''C'' '+
01554 'order by USER_NAME(t.creator) asc,t.table_name asc,c.column_id asc',
01555 [AQSNullText(TableNamePattern, '''%'''),
01556 AQSNullText(SchemaPattern, '''%'''),
01557 AQSNullText(ColumnNamePattern, '''%''')])) do
01558 begin
01559 while Next do
01560 begin
01561 while Result.GetIntByName( 'ORDINAL_POSITION') <>
01562 GetIntByName( 'column_id') do
01563 Result.Next;
01564 Result.UpdateBooleanByName( 'WRITABLE', False);
01565 Result.UpdateBooleanByName( 'DEFINITELYWRITABLE', False);
01566 Result.UpdateBooleanByName( 'READONLY', True);
01567 if GetStringByName( 'nulls') = 'N' then
01568 begin
01569 Result.UpdateShortByName( 'NULLABLE', 0);
01570 Result.UpdateStringByName( 'IS_NULLABLE', 'NO');
01571 end;
01572 Result.UpdateRow;
01573 end;
01574 Close;
01575 end;
01576 end;
01577
01578 {**
01579 Gets a description of the access rights for a table's columns.
01580
01581 <P>Only privileges matching the column name criteria are
01582 returned. They are ordered by COLUMN_NAME and PRIVILEGE.
01583
01584 <P>Each privilige description has the following columns:
01585 <OL>
01586 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
01587 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
01588 <LI><B>TABLE_NAME</B> String => table name
01589 <LI><B>COLUMN_NAME</B> String => column name
01590 <LI><B>GRANTOR</B> => grantor of access (may be null)
01591 <LI><B>GRANTEE</B> String => grantee of access
01592 <LI><B>PRIVILEGE</B> String => name of access (SELECT,
01593 INSERT, UPDATE, REFRENCES, ...)
01594 <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
01595 to grant to others; "NO" if not; null if unknown
01596 </OL>
01597
01598 @param catalog a catalog name; "" retrieves those without a
01599 catalog; null means drop catalog name from the selection criteria
01600 @param schema a schema name; "" retrieves those without a schema
01601 @param table a table name
01602 @param columnNamePattern a column name pattern
01603 @return <code>ResultSet</code> - each row is a column privilege description
01604 @see #getSearchStringEscape
01605 }
01606 function TZASADatabaseMetadata.UncachedGetColumnPrivileges(const Catalog: string;
01607 const Schema: string; const Table: string; const ColumnNamePattern: string): IZResultSet;
01608 begin
01609 Result := ConstructVirtualResultSet(TableColPrivColumnsDynArray);
01610
01611 with GetStatement.ExecuteQuery(
01612 Format('exec sp_jdbc_getcolumnprivileges %s, %s, %s, %s',
01613 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table), AQSNull(ColumnNamePattern)])) do
01614 begin
01615 while Next do
01616 begin
01617 Result.MoveToInsertRow;
01618 Result.UpdateStringByName('TABLE_CAT',
01619 '');
01620 Result.UpdateStringByName('TABLE_SCHEM',
01621 GetStringByName('TABLE_SCHEM'));
01622 Result.UpdateStringByName('TABLE_NAME',
01623 GetStringByName('TABLE_NAME'));
01624 Result.UpdateStringByName('COLUMN_NAME',
01625 GetStringByName('COLUMN_NAME'));
01626 Result.UpdateStringByName('GRANTOR',
01627 GetStringByName('GRANTOR'));
01628 Result.UpdateStringByName('GRANTEE',
01629 GetStringByName('GRANTEE'));
01630 Result.UpdateStringByName('PRIVILEGE',
01631 GetStringByName('PRIVILEGE'));
01632 Result.UpdateStringByName('IS_GRANTABLE',
01633 GetStringByName('IS_GRANTABLE'));
01634 Result.InsertRow;
01635 end;
01636 Close;
01637 end;
01638 end;
01639
01640 {**
01641 Gets a description of the access rights for each table available
01642 in a catalog. Note that a table privilege applies to one or
01643 more columns in the table. It would be wrong to assume that
01644 this priviledge applies to all columns (this may be true for
01645 some systems but is not true for all.)
01646
01647 <P>Only privileges matching the schema and table name
01648 criteria are returned. They are ordered by TABLE_SCHEM,
01649 TABLE_NAME, and PRIVILEGE.
01650
01651 <P>Each privilige description has the following columns:
01652 <OL>
01653 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
01654 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
01655 <LI><B>TABLE_NAME</B> String => table name
01656 <LI><B>GRANTOR</B> => grantor of access (may be null)
01657 <LI><B>GRANTEE</B> String => grantee of access
01658 <LI><B>PRIVILEGE</B> String => name of access (SELECT,
01659 INSERT, UPDATE, REFRENCES, ...)
01660 <LI><B>IS_GRANTABLE</B> String => "YES" if grantee is permitted
01661 to grant to others; "NO" if not; null if unknown
01662 </OL>
01663
01664 @param catalog a catalog name; "" retrieves those without a
01665 catalog; null means drop catalog name from the selection criteria
01666 @param schemaPattern a schema name pattern; "" retrieves those
01667 without a schema
01668 @param tableNamePattern a table name pattern
01669 @return <code>ResultSet</code> - each row is a table privilege description
01670 @see #getSearchStringEscape
01671 }
01672 function TZASADatabaseMetadata.UncachedGetTablePrivileges(const Catalog: string;
01673 const SchemaPattern: string; const TableNamePattern: string): IZResultSet;
01674 begin
01675 Result := ConstructVirtualResultSet(TablePrivColumnsDynArray);
01676
01677 with GetStatement.ExecuteQuery(
01678 Format('exec sp_jdbc_gettableprivileges %s, %s, %s',
01679 [AQSNull(Catalog), AQSNull(SchemaPattern), AQSNull(TableNamePattern)])) do
01680 begin
01681 while Next do
01682 begin
01683 Result.MoveToInsertRow;
01684 Result.UpdateStringByName('TABLE_CAT',
01685 '');
01686 Result.UpdateStringByName('TABLE_SCHEM',
01687 GetStringByName('TABLE_SCHEM'));
01688 Result.UpdateStringByName('TABLE_NAME',
01689 GetStringByName('TABLE_NAME'));
01690 Result.UpdateStringByName('GRANTOR',
01691 GetStringByName('GRANTOR'));
01692 Result.UpdateStringByName('GRANTEE',
01693 GetStringByName('GRANTEE'));
01694 Result.UpdateStringByName('PRIVILEGE',
01695 GetStringByName('PRIVILEGE'));
01696 Result.UpdateStringByName('IS_GRANTABLE',
01697 GetStringByName('IS_GRANTABLE'));
01698 Result.InsertRow;
01699 end;
01700 Close;
01701 end;
01702 end;
01703
01704 {**
01705 Gets a description of a table's columns that are automatically
01706 updated when any value in a row is updated. They are
01707 unordered.
01708
01709 <P>Each column description has the following columns:
01710 <OL>
01711 <LI><B>SCOPE</B> short => is not used
01712 <LI><B>COLUMN_NAME</B> String => column name
01713 <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
01714 <LI><B>TYPE_NAME</B> String => Data source dependent type name
01715 <LI><B>COLUMN_SIZE</B> int => precision
01716 <LI><B>BUFFER_LENGTH</B> int => length of column value in bytes
01717 <LI><B>DECIMAL_DIGITS</B> short => scale
01718 <LI><B>PSEUDO_COLUMN</B> short => is this a pseudo column
01719 like an Oracle ROWID
01720 <UL>
01721 <LI> versionColumnUnknown - may or may not be pseudo column
01722 <LI> versionColumnNotPseudo - is NOT a pseudo column
01723 <LI> versionColumnPseudo - is a pseudo column
01724 </UL>
01725 </OL>
01726
01727 @param catalog a catalog name; "" retrieves those without a
01728 catalog; null means drop catalog name from the selection criteria
01729 @param schema a schema name; "" retrieves those without a schema
01730 @param table a table name
01731 @return <code>ResultSet</code> - each row is a column description
01732 @exception SQLException if a database access error occurs
01733 }
01734 function TZASADatabaseMetadata.UncachedGetVersionColumns(const Catalog: string;
01735 const Schema: string; const Table: string): IZResultSet;
01736 begin
01737 Result := ConstructVirtualResultSet(TableColVerColumnsDynArray);
01738
01739 with GetStatement.ExecuteQuery(
01740 Format('exec sp_jdbc_getversioncolumns %s, %s, %s',
01741 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table)])) do
01742 begin
01743 while Next do
01744 begin
01745 Result.MoveToInsertRow;
01746 Result.UpdateShortByName('SCOPE',
01747 GetShortByName('SCOPE'));
01748 Result.UpdateStringByName('COLUMN_NAME',
01749 GetStringByName('COLUMN_NAME'));
01750 Result.UpdateShortByName('DATA_TYPE',
01751 Ord(ConvertASAJDBCToSqlType(GetShortByName('DATA_TYPE'))));
01752 Result.UpdateStringByName('TYPE_NAME',
01753 GetStringByName('TYPE_NAME'));
01754 Result.UpdateIntByName('COLUMN_SIZE',
01755 GetIntByName('COLUMN_SIZE'));
01756 Result.UpdateIntByName('BUFFER_LENGTH',
01757 GetIntByName('BUFFER_LENGTH'));
01758 Result.UpdateIntByName('DECIMAL_DIGITS',
01759 GetIntByName('DECIMAL_DIGITS'));
01760 Result.UpdateShortByName('PSEUDO_COLUMN',
01761 GetShortByName('PSEUDO_COLUMN'));
01762 Result.InsertRow;
01763 end;
01764 Close;
01765 end;
01766 end;
01767
01768 {**
01769 Gets a description of a table's primary key columns. They
01770 are ordered by COLUMN_NAME.
01771
01772 <P>Each primary key column description has the following columns:
01773 <OL>
01774 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
01775 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
01776 <LI><B>TABLE_NAME</B> String => table name
01777 <LI><B>COLUMN_NAME</B> String => column name
01778 <LI><B>KEY_SEQ</B> short => sequence number within primary key
01779 <LI><B>PK_NAME</B> String => primary key name (may be null)
01780 </OL>
01781
01782 @param catalog a catalog name; "" retrieves those without a
01783 catalog; null means drop catalog name from the selection criteria
01784 @param schema a schema name; "" retrieves those
01785 without a schema
01786 @param table a table name
01787 @return <code>ResultSet</code> - each row is a primary key column description
01788 @exception SQLException if a database access error occurs
01789 }
01790 function TZASADatabaseMetadata.UncachedGetPrimaryKeys(const Catalog: string;
01791 const Schema: string; const Table: string): IZResultSet;
01792 begin
01793 Result := ConstructVirtualResultSet(PrimaryKeyColumnsDynArray);
01794
01795 with GetStatement.ExecuteQuery(
01796 Format('exec sp_jdbc_primarykey %s, %s, %s',
01797 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table)])) do
01798 begin
01799 while Next do
01800 begin
01801 Result.MoveToInsertRow;
01802 Result.UpdateStringByName('TABLE_CAT',
01803 '');
01804 Result.UpdateStringByName('TABLE_SCHEM',
01805 GetStringByName('TABLE_SCHEM'));
01806 Result.UpdateStringByName('TABLE_NAME',
01807 GetStringByName('TABLE_NAME'));
01808 Result.UpdateStringByName('COLUMN_NAME',
01809 GetStringByName('COLUMN_NAME'));
01810 Result.UpdateShortByName('KEY_SEQ',
01811 GetShortByName('KEY_SEQ'));
01812 Result.UpdateStringByName('PK_NAME',
01813 GetStringByName('PK_NAME'));
01814 Result.InsertRow;
01815 end;
01816 Close;
01817 end;
01818 end;
01819
01820 {**
01821 Gets a description of the primary key columns that are
01822 referenced by a table's foreign key columns (the primary keys
01823 imported by a table). They are ordered by PKTABLE_CAT,
01824 PKTABLE_SCHEM, PKTABLE_NAME, and KEY_SEQ.
01825
01826 <P>Each primary key column description has the following columns:
01827 <OL>
01828 <LI><B>PKTABLE_CAT</B> String => primary key table catalog
01829 being imported (may be null)
01830 <LI><B>PKTABLE_SCHEM</B> String => primary key table schema
01831 being imported (may be null)
01832 <LI><B>PKTABLE_NAME</B> String => primary key table name
01833 being imported
01834 <LI><B>PKCOLUMN_NAME</B> String => primary key column name
01835 being imported
01836 <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
01837 <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
01838 <LI><B>FKTABLE_NAME</B> String => foreign key table name
01839 <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
01840 <LI><B>KEY_SEQ</B> short => sequence number within foreign key
01841 <LI><B>UPDATE_RULE</B> short => What happens to
01842 foreign key when primary is updated:
01843 <UL>
01844 <LI> importedNoAction - do not allow update of primary
01845 key if it has been imported
01846 <LI> importedKeyCascade - change imported key to agree
01847 with primary key update
01848 <LI> importedKeySetNull - change imported key to NULL if
01849 its primary key has been updated
01850 <LI> importedKeySetDefault - change imported key to default values
01851 if its primary key has been updated
01852 <LI> importedKeyRestrict - same as importedKeyNoAction
01853 (for ODBC 2.x compatibility)
01854 </UL>
01855 <LI><B>DELETE_RULE</B> short => What happens to
01856 the foreign key when primary is deleted.
01857 <UL>
01858 <LI> importedKeyNoAction - do not allow delete of primary
01859 key if it has been imported
01860 <LI> importedKeyCascade - delete rows that import a deleted key
01861 <LI> importedKeySetNull - change imported key to NULL if
01862 its primary key has been deleted
01863 <LI> importedKeyRestrict - same as importedKeyNoAction
01864 (for ODBC 2.x compatibility)
01865 <LI> importedKeySetDefault - change imported key to default if
01866 its primary key has been deleted
01867 </UL>
01868 <LI><B>FK_NAME</B> String => foreign key name (may be null)
01869 <LI><B>PK_NAME</B> String => primary key name (may be null)
01870 <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
01871 constraints be deferred until commit
01872 <UL>
01873 <LI> importedKeyInitiallyDeferred - see SQL92 for definition
01874 <LI> importedKeyInitiallyImmediate - see SQL92 for definition
01875 <LI> importedKeyNotDeferrable - see SQL92 for definition
01876 </UL>
01877 </OL>
01878
01879 @param catalog a catalog name; "" retrieves those without a
01880 catalog; null means drop catalog name from the selection criteria
01881 @param schema a schema name; "" retrieves those
01882 without a schema
01883 @param table a table name
01884 @return <code>ResultSet</code> - each row is a primary key column description
01885 @see #getExportedKeys
01886 }
01887 function TZASADatabaseMetadata.UncachedGetImportedKeys(const Catalog: string;
01888 const Schema: string; const Table: string): IZResultSet;
01889 begin
01890 Result := ConstructVirtualResultSet(ImportedKeyColumnsDynArray);
01891
01892 with GetStatement.ExecuteQuery(
01893 Format('exec sp_jdbc_importkey %s, %s, %s',
01894 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table)])) do
01895 begin
01896 while Next do
01897 begin
01898 Result.MoveToInsertRow;
01899 Result.UpdateStringByName('PKTABLE_CAT',
01900 '');
01901 Result.UpdateStringByName('PKTABLE_SCHEM',
01902 GetStringByName('PKTABLE_SCHEM'));
01903 Result.UpdateStringByName('PKTABLE_NAME',
01904 GetStringByName('PKTABLE_NAME'));
01905 Result.UpdateStringByName('PKCOLUMN_NAME',
01906 GetStringByName('PKCOLUMN_NAME'));
01907 Result.UpdateStringByName('FKTABLE_CAT',
01908 '');
01909 Result.UpdateStringByName('FKTABLE_SCHEM',
01910 GetStringByName('FKTABLE_SCHEM'));
01911 Result.UpdateStringByName('FKTABLE_NAME',
01912 GetStringByName('FKTABLE_NAME'));
01913 Result.UpdateStringByName('FKCOLUMN_NAME',
01914 GetStringByName('FKCOLUMN_NAME'));
01915 Result.UpdateShortByName('KEY_SEQ',
01916 GetShortByName('KEY_SEQ'));
01917 Result.UpdateShortByName('UPDATE_RULE',
01918 GetShortByName('UPDATE_RULE'));
01919 Result.UpdateShortByName('DELETE_RULE',
01920 GetShortByName('DELETE_RULE'));
01921 Result.UpdateStringByName('FK_NAME',
01922 GetStringByName('FK_NAME'));
01923 Result.UpdateStringByName('PK_NAME',
01924 GetStringByName('PK_NAME'));
01925 Result.UpdateIntByName('DEFERRABILITY',
01926 GetIntByName('DEFERRABILITY'));
01927 Result.InsertRow;
01928 end;
01929 Close;
01930 end;
01931 end;
01932
01933 {**
01934 Gets a description of the foreign key columns that reference a
01935 table's primary key columns (the foreign keys exported by a
01936 table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM,
01937 FKTABLE_NAME, and KEY_SEQ.
01938
01939 <P>Each foreign key column description has the following columns:
01940 <OL>
01941 <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
01942 <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
01943 <LI><B>PKTABLE_NAME</B> String => primary key table name
01944 <LI><B>PKCOLUMN_NAME</B> String => primary key column name
01945 <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
01946 being exported (may be null)
01947 <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
01948 being exported (may be null)
01949 <LI><B>FKTABLE_NAME</B> String => foreign key table name
01950 being exported
01951 <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
01952 being exported
01953 <LI><B>KEY_SEQ</B> short => sequence number within foreign key
01954 <LI><B>UPDATE_RULE</B> short => What happens to
01955 foreign key when primary is updated:
01956 <UL>
01957 <LI> importedNoAction - do not allow update of primary
01958 key if it has been imported
01959 <LI> importedKeyCascade - change imported key to agree
01960 with primary key update
01961 <LI> importedKeySetNull - change imported key to NULL if
01962 its primary key has been updated
01963 <LI> importedKeySetDefault - change imported key to default values
01964 if its primary key has been updated
01965 <LI> importedKeyRestrict - same as importedKeyNoAction
01966 (for ODBC 2.x compatibility)
01967 </UL>
01968 <LI><B>DELETE_RULE</B> short => What happens to
01969 the foreign key when primary is deleted.
01970 <UL>
01971 <LI> importedKeyNoAction - do not allow delete of primary
01972 key if it has been imported
01973 <LI> importedKeyCascade - delete rows that import a deleted key
01974 <LI> importedKeySetNull - change imported key to NULL if
01975 its primary key has been deleted
01976 <LI> importedKeyRestrict - same as importedKeyNoAction
01977 (for ODBC 2.x compatibility)
01978 <LI> importedKeySetDefault - change imported key to default if
01979 its primary key has been deleted
01980 </UL>
01981 <LI><B>FK_NAME</B> String => foreign key name (may be null)
01982 <LI><B>PK_NAME</B> String => primary key name (may be null)
01983 <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
01984 constraints be deferred until commit
01985 <UL>
01986 <LI> importedKeyInitiallyDeferred - see SQL92 for definition
01987 <LI> importedKeyInitiallyImmediate - see SQL92 for definition
01988 <LI> importedKeyNotDeferrable - see SQL92 for definition
01989 </UL>
01990 </OL>
01991
01992 @param catalog a catalog name; "" retrieves those without a
01993 catalog; null means drop catalog name from the selection criteria
01994 @param schema a schema name; "" retrieves those
01995 without a schema
01996 @param table a table name
01997 @return <code>ResultSet</code> - each row is a foreign key column description
01998 @see #getImportedKeys
01999 }
02000 function TZASADatabaseMetadata.UncachedGetExportedKeys(const Catalog: string;
02001 const Schema: string; const Table: string): IZResultSet;
02002 begin
02003 Result := ConstructVirtualResultSet(ExportedKeyColumnsDynArray);
02004
02005 with GetStatement.ExecuteQuery(
02006 Format('exec sp_jdbc_exportkey %s, %s, %s',
02007 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table)])) do
02008 begin
02009 while Next do
02010 begin
02011 Result.MoveToInsertRow;
02012 Result.UpdateStringByName('PKTABLE_CAT',
02013 '');
02014 Result.UpdateStringByName('PKTABLE_SCHEM',
02015 GetStringByName('PKTABLE_SCHEM'));
02016 Result.UpdateStringByName('PKTABLE_NAME',
02017 GetStringByName('PKTABLE_NAME'));
02018 Result.UpdateStringByName('PKCOLUMN_NAME',
02019 GetStringByName('PKCOLUMN_NAME'));
02020 Result.UpdateStringByName('FKTABLE_CAT',
02021 '');
02022 Result.UpdateStringByName('FKTABLE_SCHEM',
02023 GetStringByName('FKTABLE_SCHEM'));
02024 Result.UpdateStringByName('FKTABLE_NAME',
02025 GetStringByName('FKTABLE_NAME'));
02026 Result.UpdateStringByName('FKCOLUMN_NAME',
02027 GetStringByName('FKCOLUMN_NAME'));
02028 Result.UpdateShortByName('KEY_SEQ',
02029 GetShortByName('KEY_SEQ'));
02030 Result.UpdateShortByName('UPDATE_RULE',
02031 GetShortByName('UPDATE_RULE'));
02032 Result.UpdateShortByName('DELETE_RULE',
02033 GetShortByName('DELETE_RULE'));
02034 Result.UpdateStringByName('FK_NAME',
02035 GetStringByName('FK_NAME'));
02036 Result.UpdateStringByName('PK_NAME',
02037 GetStringByName('PK_NAME'));
02038 Result.UpdateIntByName('DEFERRABILITY',
02039 GetIntByName('DEFERRABILITY'));
02040 Result.InsertRow;
02041 end;
02042 Close;
02043 end;
02044 end;
02045
02046 {**
02047 Gets a description of the foreign key columns in the foreign key
02048 table that reference the primary key columns of the primary key
02049 table (describe how one table imports another's key.) This
02050 should normally return a single foreign key/primary key pair
02051 (most tables only import a foreign key from a table once.) They
02052 are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and
02053 KEY_SEQ.
02054
02055 <P>Each foreign key column description has the following columns:
02056 <OL>
02057 <LI><B>PKTABLE_CAT</B> String => primary key table catalog (may be null)
02058 <LI><B>PKTABLE_SCHEM</B> String => primary key table schema (may be null)
02059 <LI><B>PKTABLE_NAME</B> String => primary key table name
02060 <LI><B>PKCOLUMN_NAME</B> String => primary key column name
02061 <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be null)
02062 being exported (may be null)
02063 <LI><B>FKTABLE_SCHEM</B> String => foreign key table schema (may be null)
02064 being exported (may be null)
02065 <LI><B>FKTABLE_NAME</B> String => foreign key table name
02066 being exported
02067 <LI><B>FKCOLUMN_NAME</B> String => foreign key column name
02068 being exported
02069 <LI><B>KEY_SEQ</B> short => sequence number within foreign key
02070 <LI><B>UPDATE_RULE</B> short => What happens to
02071 foreign key when primary is updated:
02072 <UL>
02073 <LI> importedNoAction - do not allow update of primary
02074 key if it has been imported
02075 <LI> importedKeyCascade - change imported key to agree
02076 with primary key update
02077 <LI> importedKeySetNull - change imported key to NULL if
02078 its primary key has been updated
02079 <LI> importedKeySetDefault - change imported key to default values
02080 if its primary key has been updated
02081 <LI> importedKeyRestrict - same as importedKeyNoAction
02082 (for ODBC 2.x compatibility)
02083 </UL>
02084 <LI><B>DELETE_RULE</B> short => What happens to
02085 the foreign key when primary is deleted.
02086 <UL>
02087 <LI> importedKeyNoAction - do not allow delete of primary
02088 key if it has been imported
02089 <LI> importedKeyCascade - delete rows that import a deleted key
02090 <LI> importedKeySetNull - change imported key to NULL if
02091 its primary key has been deleted
02092 <LI> importedKeyRestrict - same as importedKeyNoAction
02093 (for ODBC 2.x compatibility)
02094 <LI> importedKeySetDefault - change imported key to default if
02095 its primary key has been deleted
02096 </UL>
02097 <LI><B>FK_NAME</B> String => foreign key name (may be null)
02098 <LI><B>PK_NAME</B> String => primary key name (may be null)
02099 <LI><B>DEFERRABILITY</B> short => can the evaluation of foreign key
02100 constraints be deferred until commit
02101 <UL>
02102 <LI> importedKeyInitiallyDeferred - see SQL92 for definition
02103 <LI> importedKeyInitiallyImmediate - see SQL92 for definition
02104 <LI> importedKeyNotDeferrable - see SQL92 for definition
02105 </UL>
02106 </OL>
02107
02108 @param primaryCatalog a catalog name; "" retrieves those without a
02109 catalog; null means drop catalog name from the selection criteria
02110 @param primarySchema a schema name; "" retrieves those
02111 without a schema
02112 @param primaryTable the table name that exports the key
02113 @param foreignCatalog a catalog name; "" retrieves those without a
02114 catalog; null means drop catalog name from the selection criteria
02115 @param foreignSchema a schema name; "" retrieves those
02116 without a schema
02117 @param foreignTable the table name that imports the key
02118 @return <code>ResultSet</code> - each row is a foreign key column description
02119 @see #getImportedKeys
02120 }
02121 function TZASADatabaseMetadata.UncachedGetCrossReference(const PrimaryCatalog: string;
02122 const PrimarySchema: string; const PrimaryTable: string; const ForeignCatalog: string;
02123 const ForeignSchema: string; const ForeignTable: string): IZResultSet;
02124 begin
02125 Result := ConstructVirtualResultSet(CrossRefColumnsDynArray);
02126
02127 with GetStatement.ExecuteQuery(
02128 Format('exec sp_jdbc_getcrossreferences %s, %s, %s, %s, %s, %s',
02129 [AQSNull(PrimaryCatalog), AQSNull(PrimarySchema), AQSNull(PrimaryTable),
02130 AQSNull(ForeignCatalog), AQSNull(ForeignSchema), AQSNull(ForeignTable)])) do
02131 begin
02132 while Next do
02133 begin
02134 Result.MoveToInsertRow;
02135 Result.UpdateStringByName('PKTABLE_CAT',
02136 '');
02137 Result.UpdateStringByName('PKTABLE_SCHEM',
02138 GetStringByName('PKTABLE_SCHEM'));
02139 Result.UpdateStringByName('PKTABLE_NAME',
02140 GetStringByName('PKTABLE_NAME'));
02141 Result.UpdateStringByName('PKCOLUMN_NAME',
02142 GetStringByName('PKCOLUMN_NAME'));
02143 Result.UpdateStringByName('FKTABLE_CAT',
02144 '');
02145 Result.UpdateStringByName('FKTABLE_SCHEM',
02146 GetStringByName('FKTABLE_SCHEM'));
02147 Result.UpdateStringByName('FKTABLE_NAME',
02148 GetStringByName('FKTABLE_NAME'));
02149 Result.UpdateStringByName('FKCOLUMN_NAME',
02150 GetStringByName('FKCOLUMN_NAME'));
02151 Result.UpdateShortByName('KEY_SEQ',
02152 GetShortByName('KEY_SEQ'));
02153 Result.UpdateShortByName('UPDATE_RULE',
02154 GetShortByName('UPDATE_RULE'));
02155 Result.UpdateShortByName('DELETE_RULE',
02156 GetShortByName('DELETE_RULE'));
02157 Result.UpdateStringByName('FK_NAME',
02158 GetStringByName('FK_NAME'));
02159 Result.UpdateStringByName('PK_NAME',
02160 GetStringByName('PK_NAME'));
02161 Result.UpdateIntByName('DEFERRABILITY',
02162 GetIntByName('DEFERRABILITY'));
02163 Result.InsertRow;
02164 end;
02165 Close;
02166 end;
02167 end;
02168
02169 {**
02170 Gets a description of all the standard SQL types supported by
02171 this database. They are ordered by DATA_TYPE and then by how
02172 closely the data type maps to the corresponding JDBC SQL type.
02173
02174 <P>Each type description has the following columns:
02175 <OL>
02176 <LI><B>TYPE_NAME</B> String => Type name
02177 <LI><B>DATA_TYPE</B> short => SQL data type from java.sql.Types
02178 <LI><B>PRECISION</B> int => maximum precision
02179 <LI><B>LITERAL_PREFIX</B> String => prefix used to quote a literal
02180 (may be null)
02181 <LI><B>LITERAL_SUFFIX</B> String => suffix used to quote a literal
02182 (may be null)
02183 <LI><B>CREATE_PARAMS</B> String => parameters used in creating
02184 the type (may be null)
02185 <LI><B>NULLABLE</B> short => can you use NULL for this type?
02186 <UL>
02187 <LI> typeNoNulls - does not allow NULL values
02188 <LI> typeNullable - allows NULL values
02189 <LI> typeNullableUnknown - nullability unknown
02190 </UL>
02191 <LI><B>CASE_SENSITIVE</B> boolean=> is it case sensitive?
02192 <LI><B>SEARCHABLE</B> short => can you use "WHERE" based on this type:
02193 <UL>
02194 <LI> typePredNone - No support
02195 <LI> typePredChar - Only supported with WHERE .. LIKE
02196 <LI> typePredBasic - Supported except for WHERE .. LIKE
02197 <LI> typeSearchable - Supported for all WHERE ..
02198 </UL>
02199 <LI><B>UNSIGNED_ATTRIBUTE</B> boolean => is it unsigned?
02200 <LI><B>FIXED_PREC_SCALE</B> boolean => can it be a money value?
02201 <LI><B>AUTO_INCREMENT</B> boolean => can it be used for an
02202 auto-increment value?
02203 <LI><B>LOCAL_TYPE_NAME</B> String => localized version of type name
02204 (may be null)
02205 <LI><B>MINIMUM_SCALE</B> short => minimum scale supported
02206 <LI><B>MAXIMUM_SCALE</B> short => maximum scale supported
02207 <LI><B>SQL_DATA_TYPE</B> int => unused
02208 <LI><B>SQL_DATETIME_SUB</B> int => unused
02209 <LI><B>NUM_PREC_RADIX</B> int => usually 2 or 10
02210 </OL>
02211
02212 @return <code>ResultSet</code> - each row is an SQL type description
02213 }
02214 function TZASADatabaseMetadata.UncachedGetTypeInfo: IZResultSet;
02215 begin
02216 Result := ConstructVirtualResultSet(TypeInfoColumnsDynArray);
02217
02218 with GetStatement.ExecuteQuery('exec sp_jdbc_datatype_info') do
02219 begin
02220 while Next do
02221 begin
02222 Result.MoveToInsertRow;
02223 Result.UpdateStringByName('TYPE_NAME',
02224 GetStringByName('TYPE_NAME'));
02225 Result.UpdateShortByName('DATA_TYPE',
02226 Ord(ConvertASAJDBCToSqlType(GetShortByName('DATA_TYPE'))));
02227 Result.UpdateIntByName('PRECISION',
02228 GetIntByName('PRECISION'));
02229 Result.UpdateStringByName('LITERAL_PREFIX',
02230 GetStringByName('LITERAL_PREFIX'));
02231 Result.UpdateStringByName('LITERAL_SUFFIX',
02232 GetStringByName('LITERAL_SUFFIX'));
02233 Result.UpdateStringByName('CREATE_PARAMS',
02234 GetStringByName('CREATE_PARAMS'));
02235 Result.UpdateShortByName('NULLABLE',
02236 GetShortByName('NULLABLE'));
02237 Result.UpdateBooleanByName('CASE_SENSITIVE',
02238 GetShortByName('CASE_SENSITIVE') = 1);
02239 Result.UpdateShortByName('SEARCHABLE',
02240 GetShortByName('SEARCHABLE'));
02241 Result.UpdateBooleanByName('UNSIGNED_ATTRIBUTE',
02242 GetShortByName('UNSIGNED_ATTRIBUTE') = 1);
02243 Result.UpdateBooleanByName('FIXED_PREC_SCALE',
02244 GetShortByName('FIXED_PREC_SCALE') = 1);
02245 Result.UpdateBooleanByName('AUTO_INCREMENT',
02246 GetShortByName('AUTO_INCREMENT') = 1);
02247 Result.UpdateStringByName('LOCAL_TYPE_NAME',
02248 GetStringByName('LOCAL_TYPE_NAME'));
02249 Result.UpdateShortByName('MINIMUM_SCALE',
02250 GetShortByName('MINIMUM_SCALE'));
02251 Result.UpdateShortByName('MAXIMUM_SCALE',
02252 GetShortByName('MAXIMUM_SCALE'));
02253 Result.UpdateShortByName('SQL_DATA_TYPE',
02254 GetShortByName('SQL_DATA_TYPE'));
02255 Result.UpdateShortByName('SQL_DATETIME_SUB',
02256 GetShortByName('SQL_DATETIME_SUB'));
02257 Result.UpdateShortByName('NUM_PREC_RADIX',
02258 GetShortByName('NUM_PREC_RADIX'));
02259 Result.InsertRow;
02260 end;
02261 Close;
02262 end;
02263 end;
02264
02265 {**
02266 Gets a description of a table's indices and statistics. They are
02267 ordered by NON_UNIQUE, TYPE, INDEX_NAME, and ORDINAL_POSITION.
02268
02269 <P>Each index column description has the following columns:
02270 <OL>
02271 <LI><B>TABLE_CAT</B> String => table catalog (may be null)
02272 <LI><B>TABLE_SCHEM</B> String => table schema (may be null)
02273 <LI><B>TABLE_NAME</B> String => table name
02274 <LI><B>NON_UNIQUE</B> boolean => Can index values be non-unique?
02275 false when TYPE is tableIndexStatistic
02276 <LI><B>INDEX_QUALIFIER</B> String => index catalog (may be null);
02277 null when TYPE is tableIndexStatistic
02278 <LI><B>INDEX_NAME</B> String => index name; null when TYPE is
02279 tableIndexStatistic
02280 <LI><B>TYPE</B> short => index type:
02281 <UL>
02282 <LI> tableIndexStatistic - this identifies table statistics that are
02283 returned in conjuction with a table's index descriptions
02284 <LI> tableIndexClustered - this is a clustered index
02285 <LI> tableIndexHashed - this is a hashed index
02286 <LI> tableIndexOther - this is some other style of index
02287 </UL>
02288 <LI><B>ORDINAL_POSITION</B> short => column sequence number
02289 within index; zero when TYPE is tableIndexStatistic
02290 <LI><B>COLUMN_NAME</B> String => column name; null when TYPE is
02291 tableIndexStatistic
02292 <LI><B>ASC_OR_DESC</B> String => column sort sequence, "A" => ascending,
02293 "D" => descending, may be null if sort sequence is not supported;
02294 null when TYPE is tableIndexStatistic
02295 <LI><B>CARDINALITY</B> int => When TYPE is tableIndexStatistic, then
02296 this is the number of rows in the table; otherwise, it is the
02297 number of unique values in the index.
02298 <LI><B>PAGES</B> int => When TYPE is tableIndexStatisic then
02299 this is the number of pages used for the table, otherwise it
02300 is the number of pages used for the current index.
02301 <LI><B>FILTER_CONDITION</B> String => Filter condition, if any.
02302 (may be null)
02303 </OL>
02304
02305 @param catalog a catalog name; "" retrieves those without a
02306 catalog; null means drop catalog name from the selection criteria
02307 @param schema a schema name; "" retrieves those without a schema
02308 @param table a table name
02309 @param unique when true, return only indices for unique values;
02310 when false, return indices regardless of whether unique or not
02311 @param approximate when true, result is allowed to reflect approximate
02312 or out of data values; when false, results are requested to be
02313 accurate
02314 @return <code>ResultSet</code> - each row is an index column description
02315 }
02316 function TZASADatabaseMetadata.UncachedGetIndexInfo(const Catalog: string;
02317 const Schema: string; const Table: string; Unique: Boolean;
02318 Approximate: Boolean): IZResultSet;
02319 var
02320 Is_Unique, Accuracy: string;
02321 begin
02322 Result := ConstructVirtualResultSet(IndexInfoColumnsDynArray);
02323
02324 if Unique then
02325 Is_Unique := '''1'''
02326 else
02327 Is_Unique := '''0''';
02328
02329 if Approximate then
02330 Accuracy := '''1'''
02331 else
02332 Accuracy := '''0''';
02333
02334 with GetStatement.ExecuteQuery(
02335 Format('exec sp_jdbc_getindexinfo %s, %s, %s, %s, %s',
02336 [AQSNull(Catalog), AQSNull(Schema), AQSNull(Table), Is_Unique, Accuracy])) do
02337 begin
02338 while Next do
02339 begin
02340 Result.MoveToInsertRow;
02341 Result.UpdateStringByName('TABLE_CAT',
02342 '');
02343 Result.UpdateStringByName('TABLE_SCHEM',
02344 GetStringByName('TABLE_SCHEM'));
02345 Result.UpdateStringByName('TABLE_NAME',
02346 GetStringByName('TABLE_NAME'));
02347 Result.UpdateBooleanByName('NON_UNIQUE',
02348 GetShortByName('NON_UNIQUE') = 1);
02349 Result.UpdateStringByName('INDEX_QUALIFIER',
02350 GetStringByName('INDEX_QUALIFIER'));
02351 Result.UpdateStringByName('INDEX_NAME',
02352 GetStringByName('INDEX_NAME'));
02353 Result.UpdateShortByName('TYPE',
02354 GetShortByName('TYPE'));
02355 Result.UpdateShortByName('ORDINAL_POSITION',
02356 GetShortByName('ORDINAL_POSITION'));
02357 Result.UpdateStringByName('COLUMN_NAME',
02358 GetStringByName('COLUMN_NAME'));
02359 Result.UpdateStringByName('ASC_OR_DESC',
02360 GetStringByName('ASC_OR_DESC'));
02361 Result.UpdateIntByName('CARDINALITY',
02362 GetIntByName('CARDINALITY'));
02363 Result.UpdateIntByName('PAGES',
02364 GetIntByName('PAGES'));
02365 Result.UpdateStringByName('FILTER_CONDITION',
02366 GetStringByName('FILTER_CONDITION'));
02367 Result.InsertRow;
02368 end;
02369 Close;
02370 end;
02371 end;
02372
02373 {**
02374 Does the database support the given result set type?
02375 @param type defined in <code>java.sql.ResultSet</code>
02376 @return <code>true</code> if so; <code>false</code> otherwise
02377 }
02378 function TZASADatabaseMetadata.SupportsResultSetType(
02379 _Type: TZResultSetType): Boolean;
02380 begin
02381 Result := True;
02382 end;
02383
02384 {**
02385 Does the database support the concurrency type in combination
02386 with the given result set type?
02387
02388 @param type defined in <code>java.sql.ResultSet</code>
02389 @param concurrency type defined in <code>java.sql.ResultSet</code>
02390 @return <code>true</code> if so; <code>false</code> otherwise
02391 }
02392 function TZASADatabaseMetadata.SupportsResultSetConcurrency(
02393 _Type: TZResultSetType; Concurrency: TZResultSetConcurrency): Boolean;
02394 begin
02395 Result := True;
02396 end;
02397
02398 {**
02399 Gets a description of the user-defined types defined in a particular
02400 schema. Schema-specific UDTs may have type JAVA_OBJECT, STRUCT,
02401 or DISTINCT.
02402
02403 <P>Only types matching the catalog, schema, type name and type
02404 criteria are returned. They are ordered by DATA_TYPE, TYPE_SCHEM
02405 and TYPE_NAME. The type name parameter may be a fully-qualified
02406 name. In this case, the catalog and schemaPattern parameters are
02407 ignored.
02408
02409 <P>Each type description has the following columns:
02410 <OL>
02411 <LI><B>TYPE_CAT</B> String => the type's catalog (may be null)
02412 <LI><B>TYPE_SCHEM</B> String => type's schema (may be null)
02413 <LI><B>TYPE_NAME</B> String => type name
02414 <LI><B>CLASS_NAME</B> String => Java class name
02415 <LI><B>DATA_TYPE</B> String => type value defined in java.sql.Types.
02416 One of JAVA_OBJECT, STRUCT, or DISTINCT
02417 <LI><B>REMARKS</B> String => explanatory comment on the type
02418 </OL>
02419
02420 <P><B>Note:</B> If the driver does not support UDTs, an empty
02421 result set is returned.
02422
02423 @param catalog a catalog name; "" retrieves those without a
02424 catalog; null means drop catalog name from the selection criteria
02425 @param schemaPattern a schema name pattern; "" retrieves those
02426 without a schema
02427 @param typeNamePattern a type name pattern; may be a fully-qualified name
02428 @param types a list of user-named types to include (JAVA_OBJECT,
02429 STRUCT, or DISTINCT); null returns all types
02430 @return <code>ResultSet</code> - each row is a type description
02431 }
02432 function TZASADatabaseMetadata.UncachedGetUDTs(const Catalog: string;
02433 const SchemaPattern: string; const TypeNamePattern: string;
02434 const Types: TIntegerDynArray): IZResultSet;
02435 var
02436 I: Integer;
02437 UDTypes: string;
02438 begin
02439 Result := ConstructVirtualResultSet(UDTColumnsDynArray);
02440
02441 UDTypes := '';
02442 for I := 0 to Length(Types) - 1 do
02443 begin
02444 if Length(UDTypes) > 0 then
02445 UDTypes := UDTypes + ',';
02446 UDTypes := UDTypes + AnsiQuotedStr(IntToStr(Types[I]), '''');
02447 end;
02448
02449 with GetStatement.ExecuteQuery(
02450 Format('exec sp_jdbc_getudts %s, %s, %s, %s',
02451 [AQSNull(Catalog), AQSNullText(SchemaPattern, '''%'''),
02452 AQSNullText(TypeNamePattern, '''%'''), AQSNull(UDTypes, '"')])) do
02453 begin
02454 while Next do
02455 begin
02456 Result.MoveToInsertRow;
02457 Result.UpdateStringByName('TYPE_CAT',
02458 GetStringByName('TYPE_CAT'));
02459 Result.UpdateStringByName('TYPE_SCHEM',
02460 GetStringByName('TYPE_SCHEM'));
02461 Result.UpdateStringByName('TYPE_NAME',
02462 GetStringByName('TYPE_NAME'));
02463 Result.UpdateStringByName('JAVA_CLASS',
02464 GetStringByName('JAVA_CLASS'));
02465 Result.UpdateShortByName('DATA_TYPE',
02466 Ord(ConvertASAJDBCToSqlType(GetShortByName('DATA_TYPE'))));
02467 Result.UpdateStringByName('REMARKS',
02468 GetStringByName('REMARKS'));
02469 Result.InsertRow;
02470 end;
02471 Close;
02472 end;
02473 end;
02474
02475 {**
02476 Create a statement for use
02477
02478 @return TZDBLibStatement
02479 }
02480 function TZASADatabaseMetadata.GetStatement: IZStatement;
02481 begin
02482 Result := GetConnection.CreateStatement;
02483 end;
02484
02485 end.
02486
02487