home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WTRANSDR.HPP < prev    next >
C/C++ Source or Header  |  1996-12-03  |  8KB  |  233 lines

  1. /*************************************************************************
  2.  *
  3.  * WODCBTransaction -- ODBC transaction interface.
  4.  *
  5.  *************************************************************************/
  6.  
  7. #ifndef _WTRANSDR_HPP_INCLUDED
  8. #define _WTRANSDR_HPP_INCLUDED
  9.  
  10. #ifndef _WREFOBJ_HPP_INCLUDED
  11. #include "wrefobj.hpp"
  12. #endif
  13. #ifndef _WTRANSAC_HPP_INCLUDED
  14. #include "wtransac.hpp"
  15. #endif
  16.  
  17. class WODBCDriver;
  18.  
  19. //
  20. // WODBCTransaction
  21. //
  22. // Specialization of WTransaction that knows how to talk to an ODBC
  23. // driver.
  24. //
  25.  
  26. class WCMCLASS WODBCTransaction : public WTransaction {
  27.  
  28.     WDeclareSubclass( WODBCTransaction, WTransaction );
  29.  
  30.     public:
  31.  
  32.         WODBCTransaction( WTransaction *proxy=NULL );
  33.  
  34.         virtual ~WODBCTransaction();
  35.  
  36.         /****************************************************************
  37.          * Properties
  38.          ****************************************************************/
  39.  
  40.         // ODBCDriver
  41.         //
  42.         //
  43.  
  44.         virtual WODBCDriver *GetODBCDriver() const;
  45.  
  46.         /***************************************************************
  47.          * Methods
  48.          ***************************************************************/
  49.  
  50.         /***************************************************************
  51.          * Overrides
  52.          ***************************************************************/
  53.  
  54.         WTAccessMode GetAccessMode() const;
  55.         WBool        SetAccessMode( WTAccessMode accessMode );
  56.  
  57.         WBool GetAutoCommit() const;
  58.         WBool SetAutoCommit( WBool autoCommit );
  59.  
  60.         WTBookmarkPersistence GetBookmarkPersistence() const;
  61.  
  62.         WBool GetConnected() const;
  63.  
  64.         WDWord GetConnectionHandle() const;
  65.  
  66.         WString GetConnectParams() const;
  67.         WBool   SetConnectParams( const WString & connectParams );
  68.  
  69.         WTCursorDriver GetCursorDriver() const;
  70.         WBool          SetCursorDriver( WTCursorDriver driv );
  71.  
  72.         WString GetDataSource() const;
  73.         WBool   SetDataSource( const WString & dataSource );
  74.  
  75.         WString GetDBMSName() const;
  76.         WBool   SetDBMSName( const WString & dbmsName );
  77.  
  78.         WBool GetDisplayErrorDialog() const;
  79.         WBool SetDisplayErrorDialog( WBool display );
  80.  
  81.         WBool GetDisplayWarningDialog() const;
  82.         WBool SetDisplayWarningDialog( WBool display );
  83.  
  84.         WDWord GetEnvironmentHandle() const;
  85.  
  86.         WLong GetErrorCode( WLong *apiFunc = NULL ) const;
  87.  
  88.         WBool GetErrorInfo( WString *errorMessage, WString *state = NULL,
  89.                             WLong *nativeErrorCode = NULL ) const;
  90.  
  91.         WDataErrorArray GetErrorList() const;
  92.  
  93.         WTFetchDirection GetFetchDirection() const;
  94.  
  95.         WTFileUsage GetFileUsage() const;
  96.  
  97.         WTIsolationLevel GetIsolationLevel() const;
  98.         WBool            SetIsolationLevel( WTIsolationLevel level );
  99.  
  100.         WString GetLoginID() const;
  101.         WBool   SetLoginID( const WString & lid );
  102.  
  103.         WString GetLoginPassword() const;
  104.         WBool   SetLoginPassword( const WString & pwd );
  105.  
  106.         WTLoginPrompt GetLoginPrompt() const;
  107.         WBool         SetLoginPrompt( WTLoginPrompt prompt );
  108.  
  109.         WLong GetMaxOptionIndex() const;
  110.  
  111.         WLong GetNumericOption( WTOptionID id ) const;
  112.         WBool SetNumericOption( WTOptionID id, const WLong value );
  113.  
  114.         WString GetPassword() const;
  115.         WBool   SetPassword( const WString & password );
  116.  
  117.         WTQualifierLocation GetQualifierLocation() const;
  118.  
  119.         WString GetQualifierSeparator() const;
  120.  
  121.         WString GetServerName() const;
  122.         WBool   SetServerName( const WString & server );
  123.  
  124.         WTStaticSensitivity GetStaticSensitivity() const;
  125.  
  126.         WString GetStringOption( WTOptionID id ) const;
  127.         WBool   SetStringOption( WTOptionID id, const WString & value );
  128.  
  129.         WTCursorTypes GetSupportedCursorTypes() const;
  130.  
  131.         WTUpdateTypes GetSupportedUpdateTypes() const;
  132.  
  133.         WBool GetTraceToLog() const;
  134.         WBool SetTraceToLog( WBool on );
  135.  
  136.         WString GetUserid() const;
  137.         WBool   SetUserid( const WString & userid );
  138.  
  139.         WTCursorCommitBehavior GetCursorCommitBehavior() const;
  140.  
  141.         WTCursorRollbackBehavior GetCursorRollbackBehavior() const;
  142.  
  143.         WBool Commit();
  144.  
  145.         WBool Connect( WWindow *parent = NULL );
  146.  
  147.         WBool Create();
  148.         WBool Create( const WString & dbmsName );
  149.  
  150.         WBool Destroy();
  151.  
  152.         WBool Disconnect();
  153.  
  154.         WBool FetchErrors( WLong, WLong );
  155.  
  156.         WBool GetDataSourceInfo( WString *name, WString *description,
  157.                                  WBool getFirst = FALSE ) const;
  158.  
  159.         WBool GetOptionInfo( WTOptionID & id, WString & name,
  160.                              WBool *isString = NULL,
  161.                              WLong index = -1 ) const;
  162.  
  163.         WBool List( WQuery & query, WTListType type, const WTListSource *source,
  164.                     const WTListSource *source2 = NULL,
  165.                     WDWord flags = WTF_ENSURE_VALIDITY );
  166.  
  167.         WBool Rollback();
  168.  
  169.     protected:
  170.  
  171.         /****************************************************************
  172.          * Internal
  173.          ****************************************************************/
  174.  
  175.         WBool CheckODBCRetCode( RETCODE rc, WLong func ) const;
  176.  
  177.         WBool BuildConnectStr();
  178.         WBool SplitConnectStr( const WString & newStr );
  179.  
  180.         WBool IsODBCOption( WTOptionID id ) const;
  181.  
  182.         /****************************************************************
  183.          * Property Data
  184.          ****************************************************************/
  185.  
  186.         WBool                       _connected;
  187.         WString                     _connectParams;
  188.         HDBC                        _connHandle;
  189.         WString                     _dataSource;
  190.         HENV                        _envHandle;
  191.         WTLoginPrompt               _loginPrompt;
  192.         WODBCDriver *               _driver;
  193.         WString                     _password;
  194.         WString                     _userid;
  195.         WDWord                      _bookmarks;
  196.         WDWord                      _fetchDirection;
  197.         WDWord                      _staticSensitivity;
  198.         WDWord                      _cursorTypes;
  199.         WDWord                      _cursorDriver;
  200.         WLong                       _qualifierLocation;
  201.         WString                     _qualifierSeparator;
  202.         WLong                       _fileUsage;
  203.         WDWord                      _updateType;
  204.         WString                     _loginID;
  205.         WString                     _loginPassword;
  206.         WString                     _serverName;
  207.         WTCursorCommitBehavior      _cursorCommitBehavior;
  208.         WTCursorRollbackBehavior    _cursorRollbackBehavior;
  209.  
  210.  
  211.         /****************************************************************
  212.          * Internal Data
  213.          ****************************************************************/
  214.  
  215.         WBool                   _fetchedError;
  216.         WString                 _connStr;       // ODBC connection string
  217.         WLong                   _lastCode;      // RC of the last ODBC call
  218.         WLong                   _lastFunc;
  219.         WDataErrorArray         _errorList;
  220.         WBool                   _displayErrors;
  221.         WBool                   _displayWarnings;
  222.  
  223.  
  224.         WTransaction *          _proxy;
  225.  
  226.         static const WConstantString    _useridKW;      // connection string keywords
  227.         static const WConstantString    _passwordKW;
  228.         static const WConstantString    _dataSourceKW;
  229.  
  230. };
  231.  
  232. #endif
  233.