📄 databasemetadata.h
字号:
/* 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; /** Provides several tons of information about a data source. * * @warning The column names in ResultSets returned by methods of * DatabaseMetaData can differ depending on what ODBC version * the current driver supports. To avoid problems, columns should * be referenced by number, and not by name. Also note that * ODBC version 2 drivers do not return some of the specified * columns. */ 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: /** Returns the Connection this came from */ Connection* getConnection() { return connection_; } /** Constants for the ResultSet returned by getBestRowIdentifier */ enum { bestRowTemporary = SQL_SCOPE_CURROW, bestRowTransaction = SQL_SCOPE_TRANSACTION, bestRowSession = SQL_SCOPE_SESSION }; /** Constants for the ResultSet returned by getBestRowIdentifier */ enum { bestRowUnknown = SQL_PC_UNKNOWN, bestRowPseudo = SQL_PC_PSEUDO, bestRowNotPseudo = SQL_PC_NOT_PSEUDO }; /** Version column constants for getVersionColumns() * @see #getVersionColumns() */ enum { versionColumnNotPseudo = SQL_PC_NOT_PSEUDO, versionColumnPseudo = SQL_PC_PSEUDO, versionColumnUnknown = SQL_PC_UNKNOWN }; /** Nullability constants for the resultset returned by getTypes() * @see getTypes() */ enum { typeNoNulls = SQL_NO_NULLS, typeNullable = SQL_NULLABLE, typeNullableUnknown = SQL_NULLABLE_UNKNOWN }; /** Nullability constants for the resultset returned by * getColumns(). * @see getColumns() */ enum { columnNoNulls = SQL_NO_NULLS, columnNullable = SQL_NULLABLE, columnNullableUnknown = SQL_NULLABLE_UNKNOWN }; /** Searchability constants */ enum { /** Column is unsearchable */ typePredNone = SQL_UNSEARCHABLE, /** Column can only be used in a LIKE clause */ typePredChar = SQL_LIKE_ONLY, /** Column can be used in searches, except in LIKE */ typePredBasic = SQL_ALL_EXCEPT_LIKE, /** Column is searchable */ typeSearchable = SQL_SEARCHABLE }; /** Imported key UPDATE_RULE and DELETE_RULE constants. * @see getImportedKeys() */#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 /** Imported key DEFERRABILITY constants */ enum { importedKeyInitiallyDeferred = SQL_INITIALLY_DEFERRED, importedKeyInitiallyImmediate = SQL_INITIALLY_IMMEDIATE, importedKeyNotDeferrable = SQL_NOT_DEFERRABLE };#endif /** Index type constants */ enum { tableIndexClustered = SQL_INDEX_CLUSTERED, tableIndexHashed = SQL_INDEX_HASHED, tableIndexOther = SQL_INDEX_OTHER, tableIndexStatistic = SQL_TABLE_STAT }; /** Procedure column type constants for getProcedureColumns() * @see #getProcedureColumns() */ 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 }; /** Procedure column nullability constants for getProcedureColumns() * @see #getProcedureColumns() */ enum { procedureNoNulls = SQL_NO_NULLS, procedureNullable = SQL_NULLABLE, procedureNullableUnknown = SQL_NULLABLE_UNKNOWN }; /** Procedure type constants for PROCEDURE_TYPE in getProcedures() * @see #getProcedures() */ enum { procedureReturnsResult = SQL_PT_FUNCTION, procedureNoResult = SQL_PT_PROCEDURE, procedureResultUnknown = SQL_PT_UNKNOWN }; /** Returns the name of the database product. */ ODBCXX_STRING getDatabaseProductName(); /** Returns the version of the database product as a string. */ ODBCXX_STRING getDatabaseProductVersion(); /** Returns the name of the ODBC driver used. */ ODBCXX_STRING getDriverName(); /** Returns the version of the ODBC driver used. */ ODBCXX_STRING getDriverVersion(); /** Returns the major ODBC version of the driver used. */ int getDriverMajorVersion(); /** Returns the minor ODBC version of the driver used. */ int getDriverMinorVersion(); /** Returns the string that can be used to quote identifiers. * If the data source doesn't support it, returns an empty string. */ ODBCXX_STRING getIdentifierQuoteString(); /** Returns the term for catalog used by the data source. * Can be for example "directory" or "database". */ ODBCXX_STRING getCatalogTerm(); /** Returns the term for schema used by the data source, * for example "owner" or just "schema". */ ODBCXX_STRING getSchemaTerm(); /** Returns the term for table used by the data source. */ ODBCXX_STRING getTableTerm(); /** Returns the term the data source uses for a procedure, * for example "stored procedure". */ ODBCXX_STRING getProcedureTerm(); /** Returns the user name of the connection. */ ODBCXX_STRING getUserName(); /** Returns the string used to separate a catalog * in a fully qualified identifier. * * For example Oracle would return a "@", while * mysql would say ".". */ ODBCXX_STRING getCatalogSeparator(); /** Returns true if the catalog is positioned at the * beginning of a fully qualified identifier. * * For example mysql would say true, while oracle would say false. */ bool isCatalogAtStart(); /** Returns a comma-separated list of all non-ODBC keywords specific * to this data source. */ ODBCXX_STRING getSQLKeywords(); /** Returns true if the data source supports transactions. */ bool supportsTransactions(); /** Returns the default transaction isolation level * @see Connection */ int getDefaultTransactionIsolation(); /** Returns true if the data source supports the specified transaction * isolation level. * @param lev The isolation level to check for */ bool supportsTransactionIsolationLevel(int lev); /** Checks if the data source supports both DML and DDL in transactions * * @return <code>true</code> if the data source supports both data manipulation * (eg. <code>UPDATE</code>, <code>INSERT</code>) and data definition * (eg. <code>CREATE TABLE</code>) within a transaction. * * * If this method returns <code>true</code>, * supportsDataManipulationTransactionsOnly(), * dataDefinitionCausesTransactionCommit() and * dataDefinitionIgnoredInTransactions() all return <code>false</code>. */ bool supportsDataDefinitionAndDataManipulationTransactions(); /** Checks if the data source only supports DML in transactions * * @return <code>true</code> if the data source only supports data manipulation * (eg. <code>UPDATE</code>, <code>INSERT</code>) within a transaction. * * Attempts to use data definition * (eg. <code>CREATE TABLE</code>) in a transaction will trigger an * error. * * If this method returns <code>true</code>, * supportsDataDefinitionAndDataManipulationTransactions(), * dataDefinitionCausesTransactionCommit() and * dataDefinitionIgnoredInTransactions() all return <code>false</code>. */ bool supportsDataManipulationTransactionsOnly(); /** Checks if DDL in a transaction will cause the transaction to be committed * * @return true if the data source only supports data manipulation * (eg. <code>UPDATE</code>, <code>INSERT</code>) within a transaction * and any data definition (eg. <code>CREATE TABLE</code>) will cause * the transaction to be committed. * * If this method returns <code>true</code>, * supportsDataDefinitionAndDataManipulationTransactions(), * supportsDataManipulationTransactionsOnly() and * dataDefinitionIgnoredInTransactions() all return <code>false</code>. */ bool dataDefinitionCausesTransactionCommit(); /** Checks if DDL in a transaction is ignored
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -