home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WDATAERR.HPP < prev    next >
C/C++ Source or Header  |  1996-08-26  |  4KB  |  134 lines

  1.  
  2. #ifndef _WDATAERR_HPP_INCLUDED
  3. #define _WDATAERR_HPP_INCLUDED
  4.  
  5. //-----------------------------------------------------------------------
  6. //
  7. // Database errors.
  8. //
  9. //-----------------------------------------------------------------------
  10.  
  11. #ifndef _WODBC_HPP_INCLUDED
  12. #include "wodbc.hpp"
  13. #endif
  14. #ifndef _WEVENT_HPP_INCLUDED
  15. #include "wevent.hpp"
  16. #endif
  17.  
  18. struct WDatabaseErrorEventData : public WEventData {
  19.     WBool isWarning;    // TRUE if only a warning
  20.     WLong errorCode;    // error or warning code
  21.     WLong apiFunction;  // code of API function
  22. };
  23.  
  24. //
  25. // WDataError
  26. //
  27. //    Holds the error information returned by a database or data source.
  28. //
  29.  
  30. class WCMCLASS WDataError : public WObject {
  31.  
  32.     WDeclareSubclass( WDataError, WObject );
  33.  
  34.     typedef WArray<WDataError> WDataErrorArray;
  35.  
  36.     public:
  37.  
  38.         WDataError();
  39.         WDataError( const WDataError & o );
  40.         WDataError( const WString & message );
  41.         WDataError( WLong errCode, WLong funcCode );
  42.         WDataError( WLong errCode, WLong funcCode, WBool fromDriver,
  43.                     const WString & message,
  44.                     const WAnsiChar *sqlState,
  45.                     WLong nativeCode );
  46.  
  47.         ~WDataError();
  48.  
  49.         WDataError & operator=( const WDataError & );
  50.         WDataError & operator=( const WString & );
  51.  
  52.         int operator==( const WDataError & ) const;
  53.         int operator!=( const WDataError & ) const;
  54.  
  55.         /***************************************************************
  56.          * Properties
  57.          ***************************************************************/
  58.  
  59.         // ErrorCode
  60.         //
  61.         //    The general error code for this error, one of the values
  62.         //    SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR,
  63.         //    SQL_NEED_DATA, SQL_NO_DATA_FOUND, SQL_INVALID_HANDLE,
  64.         //    SQL_STILL_EXECUTING, SQL_WCM_ERROR or SQL_WCM_WARNING.
  65.  
  66.         WLong GetErrorCode() const;
  67.  
  68.         // ErrorMessage
  69.         //
  70.         //    The error message.  May be a null string.
  71.  
  72.         WString GetErrorMessage() const;
  73.  
  74.         // FunctionCode
  75.         //
  76.         //    A code identifying which driver call caused the error.
  77.  
  78.         WLong GetFunctionCode() const;
  79.  
  80.         // NativeCode
  81.         //
  82.         //    The native error code, a value assigned by the database
  83.         //    driver.
  84.  
  85.         WLong GetNativeCode() const;
  86.  
  87.         // SQLState
  88.         //
  89.         //    The ODBC error state, assigned by the database driver.
  90.         //    May be a null string.
  91.  
  92.         WString GetSQLState() const;
  93.  
  94.         /***************************************************************
  95.          * Methods
  96.          ***************************************************************/
  97.  
  98.         void Clear();
  99.  
  100.         void Create( const WString & message );
  101.         void Create( const WDataError & o );
  102.         void Create( WLong errCode, WLong funcCode );
  103.         void Create( WLong errCode, WLong funcCode, WBool fromDriver,
  104.                       const WString & message, const WAnsiChar *sqlState,
  105.                       WLong nativeCode );
  106.  
  107.         /***************************************************************
  108.          * Static Properties
  109.          ***************************************************************/
  110.  
  111.         static const WDataError &      GetNullError();
  112.         static const WDataErrorArray & GetNullErrorArray();
  113.  
  114.     protected:
  115.  
  116.         /***************************************************************
  117.          * Data Members
  118.          ***************************************************************/
  119.  
  120.         WBool           _fromDriver;
  121.         WLong           _errorCode;
  122.         WLong           _functionCode;
  123.         WLong           _nativeCode;
  124.         WAnsiChar       _sqlState[10];
  125.         WString         _errorMessage;
  126. };
  127.  
  128. extern template WArrayReference<WDataError>;
  129. extern template WArray<WDataError>;
  130.  
  131. typedef WArray<WDataError> WDataErrorArray;
  132.  
  133. #endif
  134.