/* This file is part of libodbc++. Copyright (C) 1999-2000 Manush Dodunekov <manush@stendahls.net> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __ODBCXX_DATABASEMETADATA_H #define __ODBCXX_DATABASEMETADATA_H #include <odbc++/setup.h> #include <odbc++/types.h> #include <odbc++/connection.h> namespace odbc { class ResultSet; class DriverInfo; class ODBCXX_EXPORT DatabaseMetaData { friend class Connection; friend class DriverInfo; private: Connection* connection_; DatabaseMetaData(Connection* c); ~DatabaseMetaData(); const DriverInfo* _getDriverInfo() const { return connection_->_getDriverInfo(); } SQLUSMALLINT _getNumeric16(int what); SQLUINTEGER _getNumeric32(int what); ODBCXX_STRING _getStringInfo(int what); bool _ownXXXAreVisible(int type, int what); #if ODBCVER >= 0x0300 // returns all CA1 or-ed together SQLUINTEGER _getAllCursorAttributes1(); #endif public: Connection* getConnection() { return connection_; } enum { bestRowTemporary = SQL_SCOPE_CURROW, bestRowTransaction = SQL_SCOPE_TRANSACTION, bestRowSession = SQL_SCOPE_SESSION }; enum { bestRowUnknown = SQL_PC_UNKNOWN, bestRowPseudo = SQL_PC_PSEUDO, bestRowNotPseudo = SQL_PC_NOT_PSEUDO }; enum { versionColumnNotPseudo = SQL_PC_NOT_PSEUDO, versionColumnPseudo = SQL_PC_PSEUDO, versionColumnUnknown = SQL_PC_UNKNOWN }; enum { typeNoNulls = SQL_NO_NULLS, typeNullable = SQL_NULLABLE, typeNullableUnknown = SQL_NULLABLE_UNKNOWN }; enum { columnNoNulls = SQL_NO_NULLS, columnNullable = SQL_NULLABLE, columnNullableUnknown = SQL_NULLABLE_UNKNOWN }; enum { typePredNone = SQL_UNSEARCHABLE, typePredChar = SQL_LIKE_ONLY, typePredBasic = SQL_ALL_EXCEPT_LIKE, typeSearchable = SQL_SEARCHABLE }; #if ODBCVER >= 0x0300 enum { importedKeyCascade = SQL_CASCADE, importedKeySetNull = SQL_SET_NULL, importedKeySetDefault = SQL_SET_DEFAULT, importedKeyNoAction = SQL_NO_ACTION, importedKeyRestrict = SQL_RESTRICT }; #else // workaround mode on enum { importedKeyCascade = SQL_CASCADE, importedKeySetNull = SQL_SET_NULL, importedKeyRestrict = SQL_RESTRICT, importedKeyNoAction = SQL_RESTRICT, importedKeySetDefault }; #endif #if ODBCVER >= 0x0300 #if !defined(SQL_NOT_DEFERRABLE) # warning "Your sqlext.h is missing SQL_NOT_DEFERRABLE, consider upgrading" # define SQL_NOT_DEFERRABLE 7 #endif enum { importedKeyInitiallyDeferred = SQL_INITIALLY_DEFERRED, importedKeyInitiallyImmediate = SQL_INITIALLY_IMMEDIATE, importedKeyNotDeferrable = SQL_NOT_DEFERRABLE }; #endif enum { tableIndexClustered = SQL_INDEX_CLUSTERED, tableIndexHashed = SQL_INDEX_HASHED, tableIndexOther = SQL_INDEX_OTHER, tableIndexStatistic = SQL_TABLE_STAT }; enum { procedureColumnIn = SQL_PARAM_INPUT, procedureColumnInOut = SQL_PARAM_INPUT_OUTPUT, procedureColumnOut = SQL_PARAM_OUTPUT, procedureColumnResult = SQL_RESULT_COL, procedureColumnReturn = SQL_RETURN_VALUE, procedureColumnUnknown = SQL_PARAM_TYPE_UNKNOWN }; enum { procedureNoNulls = SQL_NO_NULLS, procedureNullable = SQL_NULLABLE, procedureNullableUnknown = SQL_NULLABLE_UNKNOWN }; enum { procedureReturnsResult = SQL_PT_FUNCTION, procedureNoResult = SQL_PT_PROCEDURE, procedureResultUnknown = SQL_PT_UNKNOWN }; ODBCXX_STRING getDatabaseProductName(); ODBCXX_STRING getDatabaseProductVersion(); ODBCXX_STRING getDriverName(); ODBCXX_STRING getDriverVersion(); int getDriverMajorVersion(); int getDriverMinorVersion(); ODBCXX_STRING getIdentifierQuoteString(); ODBCXX_STRING getCatalogTerm(); ODBCXX_STRING getSchemaTerm(); ODBCXX_STRING getTableTerm(); ODBCXX_STRING getProcedureTerm(); ODBCXX_STRING getUserName(); ODBCXX_STRING getCatalogSeparator(); bool isCatalogAtStart(); ODBCXX_STRING getSQLKeywords(); bool supportsTransactions(); int getDefaultTransactionIsolation(); bool supportsTransactionIsolationLevel(int lev); bool supportsDataDefinitionAndDataManipulationTransactions(); bool supportsDataManipulationTransactionsOnly(); bool dataDefinitionCausesTransactionCommit(); bool dataDefinitionIgnoredInTransactions(); bool supportsTableCorrelationNames(); bool supportsDifferentTableCorrelationNames(); bool supportsOrderByUnrelated(); bool supportsExpressionsInOrderBy(); bool supportsOpenCursorsAcrossCommit(); bool supportsOpenCursorsAcrossRollback(); bool supportsOpenStatementsAcrossCommit(); bool supportsOpenStatementsAcrossRollback(); bool supportsResultSetType(int type); bool supportsResultSetConcurrency(int type, int concurrency); bool supportsCatalogsInDataManipulation(); bool supportsCatalogsInProcedureCalls(); bool supportsCatalogsInTableDefinitions(); bool supportsCatalogsInIndexDefinitions(); bool supportsCatalogsInPrivilegeDefinitions(); bool supportsSchemasInDataManipulation(); bool supportsSchemasInProcedureCalls(); bool supportsSchemasInTableDefinitions(); bool supportsSchemasInIndexDefinitions(); bool supportsSchemasInPrivilegeDefinitions(); bool nullPlusNonNullIsNull(); bool supportsColumnAliasing(); bool supportsConvert(); bool supportsConvert(int fromType, int toType); bool supportsAlterTableWithDropColumn(); bool supportsAlterTableWithAddColumn(); ODBCXX_STRING getExtraNameCharacters(); ODBCXX_STRING getSearchStringEscape(); ODBCXX_STRING getTimeDateFunctions(); ODBCXX_STRING getSystemFunctions(); ODBCXX_STRING getStringFunctions(); ODBCXX_STRING getNumericFunctions(); bool supportsLikeEscapeClause(); bool supportsMultipleResultSets(); bool supportsMultipleTransactions(); bool supportsNonNullableColumns(); bool supportsMinimumSQLGrammar(); bool supportsCoreSQLGrammar(); bool supportsExtendedSQLGrammar(); bool supportsANSI92EntryLevelSQL(); bool supportsANSI92IntermediateSQL(); bool supportsANSI92FullSQL(); bool supportsPositionedDelete(); bool supportsPositionedUpdate(); bool supportsSelectForUpdate(); bool supportsIntegrityEnhancementFacility(); bool supportsBatchUpdates(); bool supportsSubqueriesInComparisons(); bool supportsSubqueriesInExists(); bool supportsSubqueriesInIns(); bool supportsSubqueriesInQuantifieds(); bool supportsCorrelatedSubqueries(); bool ownUpdatesAreVisible(int type); bool ownDeletesAreVisible(int type); bool ownInsertsAreVisible(int type); bool othersUpdatesAreVisible(int type); bool othersDeletesAreVisible(int type); bool othersInsertsAreVisible(int type); bool deletesAreDetected(int type); bool insertsAreDetected(int type); bool updatesAreDetected(int type); int getMaxBinaryLiteralLength(); int getMaxCharLiteralLength(); int getMaxColumnNameLength(); int getMaxColumnsInGroupBy(); int getMaxColumnsInIndex(); int getMaxColumnsInOrderBy(); int getMaxColumnsInSelect(); int getMaxColumnsInTable(); int getMaxCursorNameLength(); int getMaxIndexLength(); int getMaxSchemaNameLength(); int getMaxProcedureNameLength(); int getMaxCatalogNameLength(); int getMaxRowSize(); bool doesMaxRowSizeIncludeBlobs(); int getMaxStatementLength(); int getMaxTableNameLength(); int getMaxTablesInSelect(); int getMaxUserNameLength(); int getMaxConnections(); int getMaxStatements(); bool supportsMixedCaseIdentifiers(); bool supportsMixedCaseQuotedIdentifiers(); bool supportsStoredProcedures(); bool supportsGroupBy(); bool supportsGroupByUnrelated(); bool supportsGroupByBeyondSelect(); bool supportsUnion(); bool supportsUnionAll(); bool supportsOuterJoins(); bool supportsFullOuterJoins(); bool supportsLimitedOuterJoins(); bool usesLocalFilePerTable(); bool usesLocalFiles(); bool nullsAreSortedAtStart(); bool nullsAreSortedAtEnd(); bool nullsAreSortedHigh(); bool nullsAreSortedLow(); bool allProceduresAreCallable(); bool allTablesAreSelectable(); bool isReadOnly(); bool storesLowerCaseIdentifiers(); bool storesLowerCaseQuotedIdentifiers(); bool storesMixedCaseIdentifiers(); bool storesMixedCaseQuotedIdentifiers(); bool storesUpperCaseIdentifiers(); bool storesUpperCaseQuotedIdentifiers(); ResultSet* getTypeInfo(); ResultSet* getColumns(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schemaPattern, const ODBCXX_STRING& tableNamePattern, const ODBCXX_STRING& columnNamePattern); ResultSet* getTables(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schemaPattern, const ODBCXX_STRING& tableNamePattern, const std::vector<ODBCXX_STRING>& types); ResultSet* getTablePrivileges(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schemaPattern, const ODBCXX_STRING& tableNamePattern); ResultSet* getColumnPrivileges(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table, const ODBCXX_STRING& columnNamePattern); ResultSet* getPrimaryKeys(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table); ResultSet* getIndexInfo(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table, bool unique, bool approximate); ResultSet* getCrossReference(const ODBCXX_STRING& primaryCatalog, const ODBCXX_STRING& primarySchema, const ODBCXX_STRING& primaryTable, const ODBCXX_STRING& foreignCatalog, const ODBCXX_STRING& foreignSchema, const ODBCXX_STRING& foreignTable); ResultSet* getImportedKeys(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table) { return this->getCrossReference("","","",catalog,schema,table); } ResultSet* getExportedKeys(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table) { return this->getCrossReference(catalog,schema,table,"","",""); } ResultSet* getProcedures(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schemaPattern, const ODBCXX_STRING& procedureNamePattern); ResultSet* getProcedureColumns(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schemaPattern, const ODBCXX_STRING& procedureNamePattern, const ODBCXX_STRING& columnNamePattern); ResultSet* getBestRowIdentifier(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table, int scope, bool nullable); ResultSet* getVersionColumns(const ODBCXX_STRING& catalog, const ODBCXX_STRING& schema, const ODBCXX_STRING& table); ResultSet* getTableTypes(); ResultSet* getSchemas(); ResultSet* getCatalogs(); }; }; // namespace odbc #endif // __ODBCXX_DATABASEMETADATA_H