home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef _WODBCDR_HPP_INCLUDED
- #define _WODBCDR_HPP_INCLUDED
-
- //----------------------------------------------------------------------
- //
- // WODBCDriver -- ODBC Driver cover class
- //
- // Use this class to dynamically load an ODBC DLL (by default, ODBC32.DLL).
- // Each ODBC 2.0 API function is covered.
- //
- // Sample use:
- //
- // WODBCDriver *driver = WODBCDriver::Load( "ODBC32" );
- //
- // driver->SQLAllocEnv( ... );
- //
- // Drivers are automatically unloaded on program termination. If you
- // wish to free them beforehand, call WODBCDriver::Unload (do not try
- // to delete them).
- //
- //-----------------------------------------------------------------------
-
- #ifndef _WODBC_HPP_INCLUDED
- #include "wodbc.hpp"
- #endif
- #ifndef _WMODULE_HPP_INCLUDED
- #include "wmodule.hpp"
- #endif
- #ifndef _WDATAERR_HPP_INCLUDED
- #include "wdataerr.hpp"
- #endif
-
- //
- // Define our ODBC cover class. This class lets us talk to any
- // DLL that exposes an ODBC set of interface functions.
- //
-
- class WCMCLASS WODBCDriver : public WObject {
-
- protected:
-
- WODBCDriver( const WChar *name, const WModule & module );
-
- public:
-
- ~WODBCDriver();
-
- // Name
-
- WString GetName() const;
-
- // DisplayErrors
-
- WBool DisplayErrors( const WDataErrorArray & errors );
-
- // Environment Handle
-
- HENV ReferenceEnvironment();
- WBool UnreferenceEnvironment();
-
- // FetchErrors
- //
- // Call SQLError and build an array of WDataErrors.
-
- WDataErrorArray FetchErrors( HENV env, HDBC conn, HSTMT stmt,
- WLong rc, WLong funcCode=0,
- const WChar *prefix=NULL );
-
- // APIName
- //
- // Return the name associated with an API function code.
-
- static WString GetAPIName( int funcCode );
-
- // RetcodeName
- //
- // Return the string identifying a return code value.
-
- static WString GetRetcodeName( RETCODE rc );
-
- // Load
- //
- // Load an ODBC driver. If no name is specified, defaults
- // to "ODBC32". Returns a pointer to a WODBCDriver.
- // The user must not free this pointer.
-
- static WODBCDriver *Load( const WChar *name=NULL );
-
- // Unload
- //
- // Unloads an ODBC driver and frees the WODBCDriver
- // associated with it.
-
- static WBool Unload( const WChar *name=NULL );
-
- /****************************************************************
- * SQL Functions
- ****************************************************************/
-
- /* API functions -- environment */
-
- RETCODE SQLAllocEnv( HENV *phenv );
-
- RETCODE SQLError( HENV henv, HDBC hdbc, HSTMT hstmt,
- UCHAR *szSqlState, SDWORD *pfNativeError,
- UCHAR *szErrorMsg, SWORD cbErrorMsgMax,
- SWORD *pcbErrorMsg );
-
- RETCODE SQLDataSources( HENV henv, UWORD fDirection,
- UCHAR *szDSN,
- SWORD cbDSNMax, SWORD *pcbDSN,
- UCHAR *szDescription,
- SWORD cbDescriptionMax,
- SWORD *pcbDescription );
-
- RETCODE SQLFreeEnv( HENV env );
-
- /* API functions -- connections */
-
- RETCODE SQLAllocConnect( HENV henv, HDBC *phdbc );
-
- RETCODE SQLConnect( HDBC hdbc, UCHAR *szDSN,
- SWORD cbDSN, UCHAR *szUID,
- SWORD cbUID, UCHAR *szAuthStr,
- SWORD cbAuthStr );
-
- RETCODE SQLDriverConnect( HDBC hdbc, HWND hwnd,
- UCHAR *szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR *szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD *pcbConnStrOut,
- UWORD fDriverCompletion );
-
- RETCODE SQLBrowseConnect(
- HDBC hdbc,
- UCHAR * szConnStrIn,
- SWORD cbConnStrIn,
- UCHAR * szConnStrOut,
- SWORD cbConnStrOutMax,
- SWORD * pcbConnStrOut );
-
- RETCODE SQLDrivers(
- HENV henv,
- UWORD fDirection,
- UCHAR * *szDriverDesc,
- SWORD cbDriverDescMax,
- SWORD * *pcbDriverDesc,
- UCHAR * *szDriverAttributes,
- SWORD cbDrvrAttrMax,
- SWORD * *pcbDrvrAttr );
-
- RETCODE SQLGetConnectOption(
- HDBC hdbc,
- UWORD fOption,
- PTR pvParam );
-
- RETCODE SQLSetConnectOption(
- HDBC hdbc,
- UWORD fOption,
- UDWORD vParam );
-
- RETCODE SQLNativeSql(
- HDBC hdbc,
- UCHAR * szSqlStrIn,
- SDWORD cbSqlStrIn,
- UCHAR * szSqlStr,
- SDWORD cbSqlStrMax,
- SDWORD * pcbSqlStr );
-
- RETCODE SQLTransact(
- HENV henv,
- HDBC hdbc,
- UWORD fType );
-
- RETCODE SQLDisconnect(
- HDBC hdbc );
-
- RETCODE SQLFreeConnect(
- HDBC hdbc );
-
- /* API functions -- driver information */
-
- RETCODE SQLGetFunctions(
- HDBC hdbc,
- UWORD fFunction, UWORD *pfExists );
-
- RETCODE SQLGetInfo(
- HDBC hdbc,
- UWORD fInfoType,
- PTR rgbInfoValue,
- SWORD cbInfoValueMax,
- SWORD * pcbInfoValue );
-
- /* API functions -- statements */
-
- RETCODE SQLAllocStmt(
- HDBC hdbc,
- HSTMT * phstmt );
-
- RETCODE SQLCancel(
- HSTMT hstmt );
-
- RETCODE SQLExecDirect(
- HSTMT hstmt,
- UCHAR * szSqlStr,
- SDWORD cbSqlStr );
-
- RETCODE SQLPrepare(
- HSTMT hstmt,
- UCHAR * szSqlStr,
- SDWORD cbSqlStr );
-
- RETCODE SQLExecute(
- HSTMT hstmt );
-
- RETCODE SQLGetStmtOption(
- HSTMT hstmt,
- UWORD fOption,
- PTR pvParam );
-
- RETCODE SQLSetStmtOption(
- HSTMT hstmt,
- UWORD fOption,
- UDWORD vParam );
-
- RETCODE SQLFreeStmt(
- HSTMT hstmt,
- UWORD fOption );
-
- /* Result related functions */
-
- RETCODE SQLBindCol(
- HSTMT hstmt,
- UWORD icol,
- SWORD fCType,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD * pcbValue );
-
- RETCODE SQLColAttributes(
- HSTMT hstmt,
- UWORD icol,
- UWORD fDescType,
- PTR rgbDesc,
- SWORD cbDescMax,
- SWORD * pcbDesc,
- SDWORD * pfDesc );
-
- RETCODE SQLDescribeCol(
- HSTMT hstmt,
- UWORD icol,
- UCHAR * szColName,
- SWORD cbColNameMax,
- SWORD * pcbColName,
- SWORD * pfSqlType,
- UDWORD * pcbColDef,
- SWORD * pibScale,
- SWORD * pfNullable );
-
- RETCODE SQLFetch(
- HSTMT hstmt );
-
- RETCODE SQLExtendedFetch(
- HSTMT hstmt,
- UWORD fFetchType,
- SDWORD irow,
- UDWORD * pcrow,
- UWORD * rgfRowStatus );
-
- RETCODE SQLSetPos(
- HSTMT hstmt,
- UWORD irow,
- UWORD fRefresh,
- UWORD fLock );
-
- RETCODE SQLSetScrollOptions(
- HSTMT hstmt,
- UWORD fConcurrency,
- SDWORD crowKeySet,
- UWORD crowRowSet );
-
- RETCODE SQLGetCursorName(
- HSTMT hstmt,
- UCHAR * szCursor,
- SWORD cbCursorMax,
- SWORD * pcbCursor );
-
- RETCODE SQLGetData(
- HSTMT hstmt,
- UWORD icol,
- SWORD fCType,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD * pcbValue );
-
- RETCODE SQLNumResultCols(
- HSTMT hstmt,
- SWORD * pccol );
-
- RETCODE SQLRowCount(
- HSTMT hstmt,
- SDWORD * pcrow );
-
- RETCODE SQLSetCursorName(
- HSTMT hstmt,
- UCHAR * szCursor,
- SWORD cbCursor );
-
- /* Parameters */
-
- RETCODE SQLNumParams(
- HSTMT hstmt,
- SWORD * pcpar );
-
- RETCODE SQLDescribeParam(
- HSTMT hstmt,
- UWORD ipar,
- SWORD * pfSqlType,
- UDWORD * pcbColDef,
- SWORD * pibScale,
- SWORD * pfNullable );
-
- RETCODE SQLBindParameter(
- HSTMT hstmt,
- UWORD ipar,
- SWORD fParamType,
- SWORD fCType,
- SWORD fSqlType,
- UDWORD cbColDef,
- SWORD ibScale,
- PTR rgbValue,
- SDWORD cbValueMax,
- SDWORD * pcbValue );
-
- RETCODE SQLSetParam(
- HSTMT hstmt,
- UWORD ipar,
- SWORD fCType,
- SWORD fSqlType,
- UDWORD cbColDef,
- SWORD ibScale,
- PTR rgbValue,
- SDWORD * pcbValue );
-
- RETCODE SQLParamData(
- HSTMT hstmt,
- PTR * prgbValue );
-
- RETCODE SQLPutData(
- HSTMT hstmt,
- PTR rgbValue,
- SDWORD cbValue );
-
- RETCODE SQLMoreResults(
- HSTMT hstmt );
-
- RETCODE SQLParamOptions(
- HSTMT hstmt,
- UDWORD crow,
- UDWORD * pirow );
-
- /* Catalog information */
-
- RETCODE SQLColumnPrivileges(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName,
- UCHAR * szColumnName,
- SWORD cbColumnName );
-
- RETCODE SQLTablePrivileges(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName );
-
- RETCODE SQLColumns(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName,
- UCHAR * szColumnName,
- SWORD cbColumnName );
-
- RETCODE SQLForeignKeys(
- HSTMT hstmt,
- UCHAR * szPkTableQualifier,
- SWORD cbPkTableQualifier,
- UCHAR * szPkTableOwner,
- SWORD cbPkTableOwner,
- UCHAR * szPkTableName,
- SWORD cbPkTableName,
- UCHAR * szFkTableQualifier,
- SWORD cbFkTableQualifier,
- UCHAR * szFkTableOwner,
- SWORD cbFkTableOwner,
- UCHAR * szFkTableName,
- SWORD cbFkTableName );
-
- RETCODE SQLGetTypeInfo(
- HSTMT hstmt,
- SWORD fSqlType );
-
- RETCODE SQLPrimaryKeys(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName );
-
- RETCODE SQLProcedureColumns(
- HSTMT hstmt,
- UCHAR * szProcQualifier,
- SWORD cbProcQualifier,
- UCHAR * szProcOwner,
- SWORD cbProcOwner,
- UCHAR * szProcName,
- SWORD cbProcName,
- UCHAR * szColumnName,
- SWORD cbColumnName );
-
- RETCODE SQLProcedures(
- HSTMT hstmt,
- UCHAR * szProcQualifier,
- SWORD cbProcQualifier,
- UCHAR * szProcOwner,
- SWORD cbProcOwner,
- UCHAR * szProcName,
- SWORD cbProcName );
-
- RETCODE SQLSpecialColumns(
- HSTMT hstmt,
- UWORD fColType,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName,
- UWORD fScope,
- UWORD fNullable );
-
- RETCODE SQLStatistics(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName,
- UWORD fUnique,
- UWORD fAccuracy );
-
- RETCODE SQLTables(
- HSTMT hstmt,
- UCHAR * szTableQualifier,
- SWORD cbTableQualifier,
- UCHAR * szTableOwner,
- SWORD cbTableOwner,
- UCHAR * szTableName,
- SWORD cbTableName,
- UCHAR * szTableType,
- SWORD cbTableType );
-
- protected:
-
- WModule _module;
- WString _name;
- HENV _envHandle;
- WInt _envCount;
- void *_jumpTable[ SQL_API_END_OF_FUNCTIONS ];
- WDataErrorArray _ignoreList;
- };
-
- #endif
-