00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __ODBCXX_DATABASEMETADATA_H
00023 #define __ODBCXX_DATABASEMETADATA_H
00024
00025 #include <odbc++/setup.h>
00026 #include <odbc++/types.h>
00027 #include <odbc++/connection.h>
00028
00029 namespace odbc {
00030
00031 class ResultSet;
00032 class DriverInfo;
00033
00043 class ODBCXX_EXPORT DatabaseMetaData {
00044 friend class Connection;
00045 friend class DriverInfo;
00046
00047 private:
00048 Connection* connection_;
00049
00050 DatabaseMetaData(Connection* c);
00051 ~DatabaseMetaData();
00052
00053 const DriverInfo* _getDriverInfo() const {
00054 return connection_->_getDriverInfo();
00055 }
00056
00057 SQLUSMALLINT _getNumeric16(int what);
00058 SQLUINTEGER _getNumeric32(int what);
00059
00060 ODBCXX_STRING _getStringInfo(int what);
00061 bool _ownXXXAreVisible(int type, int what);
00062
00063 #if ODBCVER >= 0x0300
00064
00065 SQLUINTEGER _getAllCursorAttributes1();
00066 #endif
00067
00068 public:
00069
00071 Connection* getConnection() {
00072 return connection_;
00073 }
00074
00076 enum {
00077 bestRowTemporary = SQL_SCOPE_CURROW,
00078 bestRowTransaction = SQL_SCOPE_TRANSACTION,
00079 bestRowSession = SQL_SCOPE_SESSION
00080 };
00081
00083 enum {
00084 bestRowUnknown = SQL_PC_UNKNOWN,
00085 bestRowPseudo = SQL_PC_PSEUDO,
00086 bestRowNotPseudo = SQL_PC_NOT_PSEUDO
00087 };
00088
00089
00093 enum {
00094 versionColumnNotPseudo = SQL_PC_NOT_PSEUDO,
00095 versionColumnPseudo = SQL_PC_PSEUDO,
00096 versionColumnUnknown = SQL_PC_UNKNOWN
00097 };
00098
00099
00103 enum {
00104 typeNoNulls = SQL_NO_NULLS,
00105 typeNullable = SQL_NULLABLE,
00106 typeNullableUnknown = SQL_NULLABLE_UNKNOWN
00107 };
00108
00113 enum {
00114 columnNoNulls = SQL_NO_NULLS,
00115 columnNullable = SQL_NULLABLE,
00116 columnNullableUnknown = SQL_NULLABLE_UNKNOWN
00117 };
00118
00120 enum {
00122 typePredNone = SQL_UNSEARCHABLE,
00124 typePredChar = SQL_LIKE_ONLY,
00126 typePredBasic = SQL_ALL_EXCEPT_LIKE,
00128 typeSearchable = SQL_SEARCHABLE
00129 };
00130
00131
00135 #if ODBCVER >= 0x0300
00136 enum {
00137 importedKeyCascade = SQL_CASCADE,
00138 importedKeySetNull = SQL_SET_NULL,
00139 importedKeySetDefault = SQL_SET_DEFAULT,
00140 importedKeyNoAction = SQL_NO_ACTION,
00141 importedKeyRestrict = SQL_RESTRICT
00142 };
00143 #else
00144
00145 enum {
00146 importedKeyCascade = SQL_CASCADE,
00147 importedKeySetNull = SQL_SET_NULL,
00148 importedKeyRestrict = SQL_RESTRICT,
00149 importedKeyNoAction = SQL_RESTRICT,
00150 importedKeySetDefault
00151 };
00152
00153 #endif
00154
00155 #if ODBCVER >= 0x0300
00156 #if !defined(SQL_NOT_DEFERRABLE)
00157 # warning "Your sqlext.h is missing SQL_NOT_DEFERRABLE, consider upgrading"
00158 # define SQL_NOT_DEFERRABLE 7
00159 #endif
00160
00161 enum {
00162 importedKeyInitiallyDeferred = SQL_INITIALLY_DEFERRED,
00163 importedKeyInitiallyImmediate = SQL_INITIALLY_IMMEDIATE,
00164 importedKeyNotDeferrable = SQL_NOT_DEFERRABLE
00165 };
00166 #endif
00167
00169 enum {
00170 tableIndexClustered = SQL_INDEX_CLUSTERED,
00171 tableIndexHashed = SQL_INDEX_HASHED,
00172 tableIndexOther = SQL_INDEX_OTHER,
00173 tableIndexStatistic = SQL_TABLE_STAT
00174 };
00175
00179 enum {
00180 procedureColumnIn = SQL_PARAM_INPUT,
00181 procedureColumnInOut = SQL_PARAM_INPUT_OUTPUT,
00182 procedureColumnOut = SQL_PARAM_OUTPUT,
00183 procedureColumnResult = SQL_RESULT_COL,
00184 procedureColumnReturn = SQL_RETURN_VALUE,
00185 procedureColumnUnknown = SQL_PARAM_TYPE_UNKNOWN
00186 };
00187
00191 enum {
00192 procedureNoNulls = SQL_NO_NULLS,
00193 procedureNullable = SQL_NULLABLE,
00194 procedureNullableUnknown = SQL_NULLABLE_UNKNOWN
00195 };
00196
00200 enum {
00201 procedureReturnsResult = SQL_PT_FUNCTION,
00202 procedureNoResult = SQL_PT_PROCEDURE,
00203 procedureResultUnknown = SQL_PT_UNKNOWN
00204 };
00205
00206
00207
00210 ODBCXX_STRING getDatabaseProductName();
00211
00214 ODBCXX_STRING getDatabaseProductVersion();
00215
00218 ODBCXX_STRING getDriverName();
00219
00222 ODBCXX_STRING getDriverVersion();
00223
00225 int getDriverMajorVersion();
00226
00228 int getDriverMinorVersion();
00229
00233 ODBCXX_STRING getIdentifierQuoteString();
00234
00238 ODBCXX_STRING getCatalogTerm();
00239
00243 ODBCXX_STRING getSchemaTerm();
00244
00247 ODBCXX_STRING getTableTerm();
00248
00252 ODBCXX_STRING getProcedureTerm();
00253
00256 ODBCXX_STRING getUserName();
00257
00264 ODBCXX_STRING getCatalogSeparator();
00265
00271 bool isCatalogAtStart();
00272
00276 ODBCXX_STRING getSQLKeywords();
00277
00278
00281 bool supportsTransactions();
00282
00286 int getDefaultTransactionIsolation();
00287
00292 bool supportsTransactionIsolationLevel(int lev);
00293
00306 bool supportsDataDefinitionAndDataManipulationTransactions();
00307
00322 bool supportsDataManipulationTransactionsOnly();
00323
00336 bool dataDefinitionCausesTransactionCommit();
00337
00350 bool dataDefinitionIgnoredInTransactions();
00351
00352
00355 bool supportsTableCorrelationNames();
00356
00359 bool supportsDifferentTableCorrelationNames();
00360
00363 bool supportsOrderByUnrelated();
00364
00367 bool supportsExpressionsInOrderBy();
00368
00373 bool supportsOpenCursorsAcrossCommit();
00374
00375
00380 bool supportsOpenCursorsAcrossRollback();
00381
00382
00387 bool supportsOpenStatementsAcrossCommit();
00388
00393 bool supportsOpenStatementsAcrossRollback();
00394
00400 bool supportsResultSetType(int type);
00401
00408 bool supportsResultSetConcurrency(int type, int concurrency);
00409
00410
00412 bool supportsCatalogsInDataManipulation();
00413
00415 bool supportsCatalogsInProcedureCalls();
00416
00418 bool supportsCatalogsInTableDefinitions();
00419
00421 bool supportsCatalogsInIndexDefinitions();
00422
00424 bool supportsCatalogsInPrivilegeDefinitions();
00425
00426
00428 bool supportsSchemasInDataManipulation();
00429
00431 bool supportsSchemasInProcedureCalls();
00432
00434 bool supportsSchemasInTableDefinitions();
00435
00437 bool supportsSchemasInIndexDefinitions();
00438
00440 bool supportsSchemasInPrivilegeDefinitions();
00441
00442
00445 bool nullPlusNonNullIsNull();
00446
00450 bool supportsColumnAliasing();
00451
00454 bool supportsConvert();
00455
00458 bool supportsConvert(int fromType, int toType);
00459
00462 bool supportsAlterTableWithDropColumn();
00463
00466 bool supportsAlterTableWithAddColumn();
00467
00471 ODBCXX_STRING getExtraNameCharacters();
00472
00475 ODBCXX_STRING getSearchStringEscape();
00476
00479 ODBCXX_STRING getTimeDateFunctions();
00480
00483 ODBCXX_STRING getSystemFunctions();
00484
00487 ODBCXX_STRING getStringFunctions();
00488
00491 ODBCXX_STRING getNumericFunctions();
00492
00495 bool supportsLikeEscapeClause();
00496
00499 bool supportsMultipleResultSets();
00500
00504 bool supportsMultipleTransactions();
00505
00508 bool supportsNonNullableColumns();
00509
00512 bool supportsMinimumSQLGrammar();
00513
00516 bool supportsCoreSQLGrammar();
00517
00520 bool supportsExtendedSQLGrammar();
00521
00522
00526 bool supportsANSI92EntryLevelSQL();
00527
00531 bool supportsANSI92IntermediateSQL();
00532
00535 bool supportsANSI92FullSQL();
00536
00542 bool supportsPositionedDelete();
00543
00549 bool supportsPositionedUpdate();
00550
00556 bool supportsSelectForUpdate();
00557
00558
00562 bool supportsIntegrityEnhancementFacility();
00563
00566 bool supportsBatchUpdates();
00567
00570 bool supportsSubqueriesInComparisons();
00571
00575 bool supportsSubqueriesInExists();
00576
00580 bool supportsSubqueriesInIns();
00581
00585 bool supportsSubqueriesInQuantifieds();
00586
00587
00590 bool supportsCorrelatedSubqueries();
00591
00596 bool ownUpdatesAreVisible(int type);
00597
00601 bool ownDeletesAreVisible(int type);
00602
00606 bool ownInsertsAreVisible(int type);
00607
00612 bool othersUpdatesAreVisible(int type);
00613
00618 bool othersDeletesAreVisible(int type);
00619
00624 bool othersInsertsAreVisible(int type);
00625
00630 bool deletesAreDetected(int type);
00631
00636 bool insertsAreDetected(int type);
00637
00642 bool updatesAreDetected(int type);
00643
00644
00648 int getMaxBinaryLiteralLength();
00649
00652 int getMaxCharLiteralLength();
00653
00656 int getMaxColumnNameLength();
00657
00661 int getMaxColumnsInGroupBy();
00662
00665 int getMaxColumnsInIndex();
00666
00670 int getMaxColumnsInOrderBy();
00671
00674 int getMaxColumnsInSelect();
00675
00678 int getMaxColumnsInTable();
00679
00682 int getMaxCursorNameLength();
00683
00686 int getMaxIndexLength();
00687
00690 int getMaxSchemaNameLength();
00691
00694 int getMaxProcedureNameLength();
00695
00698 int getMaxCatalogNameLength();
00699
00702 int getMaxRowSize();
00703
00707 bool doesMaxRowSizeIncludeBlobs();
00708
00709
00712 int getMaxStatementLength();
00713
00716 int getMaxTableNameLength();
00717
00721 int getMaxTablesInSelect();
00722
00725 int getMaxUserNameLength();
00726
00730 int getMaxConnections();
00731
00735 int getMaxStatements();
00736
00737
00741 bool supportsMixedCaseIdentifiers();
00742
00746 bool supportsMixedCaseQuotedIdentifiers();
00747
00751 bool supportsStoredProcedures();
00752
00753
00757 bool supportsGroupBy();
00758
00762 bool supportsGroupByUnrelated();
00763
00767 bool supportsGroupByBeyondSelect();
00768
00769
00772 bool supportsUnion();
00773
00776 bool supportsUnionAll();
00777
00781 bool supportsOuterJoins();
00782
00785 bool supportsFullOuterJoins();
00786
00790 bool supportsLimitedOuterJoins();
00791
00793 bool usesLocalFilePerTable();
00794
00796 bool usesLocalFiles();
00797
00801 bool nullsAreSortedAtStart();
00802
00806 bool nullsAreSortedAtEnd();
00807
00810 bool nullsAreSortedHigh();
00811
00814 bool nullsAreSortedLow();
00815
00819 bool allProceduresAreCallable();
00820
00824 bool allTablesAreSelectable();
00825
00829 bool isReadOnly();
00830
00834 bool storesLowerCaseIdentifiers();
00835
00839 bool storesLowerCaseQuotedIdentifiers();
00840
00844 bool storesMixedCaseIdentifiers();
00845
00849 bool storesMixedCaseQuotedIdentifiers();
00850
00854 bool storesUpperCaseIdentifiers();
00855
00859 bool storesUpperCaseQuotedIdentifiers();
00860
00861
00908 ResultSet* getTypeInfo();
00909
00945 ResultSet* getColumns(const ODBCXX_STRING& catalog,
00946 const ODBCXX_STRING& schemaPattern,
00947 const ODBCXX_STRING& tableNamePattern,
00948 const ODBCXX_STRING& columnNamePattern);
00949
00950
00965 ResultSet* getTables(const ODBCXX_STRING& catalog,
00966 const ODBCXX_STRING& schemaPattern,
00967 const ODBCXX_STRING& tableNamePattern,
00968 const std::vector<ODBCXX_STRING>& types);
00969
00994 ResultSet* getTablePrivileges(const ODBCXX_STRING& catalog,
00995 const ODBCXX_STRING& schemaPattern,
00996 const ODBCXX_STRING& tableNamePattern);
00997
00998
01021 ResultSet* getColumnPrivileges(const ODBCXX_STRING& catalog,
01022 const ODBCXX_STRING& schema,
01023 const ODBCXX_STRING& table,
01024 const ODBCXX_STRING& columnNamePattern);
01025
01041 ResultSet* getPrimaryKeys(const ODBCXX_STRING& catalog,
01042 const ODBCXX_STRING& schema,
01043 const ODBCXX_STRING& table);
01044
01045
01091 ResultSet* getIndexInfo(const ODBCXX_STRING& catalog,
01092 const ODBCXX_STRING& schema,
01093 const ODBCXX_STRING& table,
01094 bool unique, bool approximate);
01095
01140 ResultSet* getCrossReference(const ODBCXX_STRING& primaryCatalog,
01141 const ODBCXX_STRING& primarySchema,
01142 const ODBCXX_STRING& primaryTable,
01143 const ODBCXX_STRING& foreignCatalog,
01144 const ODBCXX_STRING& foreignSchema,
01145 const ODBCXX_STRING& foreignTable);
01146
01155 ResultSet* getImportedKeys(const ODBCXX_STRING& catalog,
01156 const ODBCXX_STRING& schema,
01157 const ODBCXX_STRING& table) {
01158 return this->getCrossReference("","","",catalog,schema,table);
01159 }
01160
01167 ResultSet* getExportedKeys(const ODBCXX_STRING& catalog,
01168 const ODBCXX_STRING& schema,
01169 const ODBCXX_STRING& table) {
01170 return this->getCrossReference(catalog,schema,table,"","","");
01171 }
01172
01195 ResultSet* getProcedures(const ODBCXX_STRING& catalog,
01196 const ODBCXX_STRING& schemaPattern,
01197 const ODBCXX_STRING& procedureNamePattern);
01198
01238 ResultSet* getProcedureColumns(const ODBCXX_STRING& catalog,
01239 const ODBCXX_STRING& schemaPattern,
01240 const ODBCXX_STRING& procedureNamePattern,
01241 const ODBCXX_STRING& columnNamePattern);
01242
01243
01279 ResultSet* getBestRowIdentifier(const ODBCXX_STRING& catalog,
01280 const ODBCXX_STRING& schema,
01281 const ODBCXX_STRING& table,
01282 int scope,
01283 bool nullable);
01284
01307 ResultSet* getVersionColumns(const ODBCXX_STRING& catalog,
01308 const ODBCXX_STRING& schema,
01309 const ODBCXX_STRING& table);
01310
01311
01312
01318 ResultSet* getTableTypes();
01319
01325 ResultSet* getSchemas();
01326
01332 ResultSet* getCatalogs();
01333 };
01334
01335
01336 };
01337
01338
01339 #endif // __ODBCXX_DATABASEMETADATA_H