00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef ODBCPP_DIAG
00025 #define ODBCPP_DIAG
00026
00027 #include "odbcpp_config.h"
00028 #include <sql.h>
00029 #include <string>
00030 #include <vector>
00031
00032 namespace odbcpp
00033 {
00034
00035 class diag_t
00036 {
00037 public:
00038 diag_t();
00039
00040 std::string msg() const;
00041
00042 std::string f_server;
00043 std::string f_connection;
00044 std::string f_message;
00045 std::string f_odbc_state;
00046 SQLINTEGER f_native_errno;
00047 };
00049 typedef std::vector<diag_t> diag_vector_t;
00050
00051
00052 class handle;
00053
00054
00055 class diagnostic
00056 {
00057 public:
00058 diagnostic() {}
00059 diagnostic(SQLINTEGER odbcpp_errno, const std::string& message);
00060 diagnostic(SQLSMALLINT handle_type, SQLHANDLE hdl, handle *parent = 0);
00061
00062 void set(SQLSMALLINT handle_type, SQLHANDLE handle);
00063 std::string msg() const;
00064
00065 SQLLEN get_affected_rows() const { return f_affected_rows; }
00066 SQLSMALLINT size() const { return static_cast<SQLSMALLINT>(f_diag.size()); }
00067 diag_t get(SQLSMALLINT record) const { return f_diag[static_cast<int>(record) - 1]; }
00068 diag_t operator [] (int record) const { return f_diag[record - 1]; }
00069
00070 static bool get_string(SQLSMALLINT handle_type, SQLHANDLE handle, SQLSMALLINT record, SQLSMALLINT identifier, std::string& string);
00071 static bool get_integer(SQLSMALLINT handle_type, SQLHANDLE handle, SQLSMALLINT record, SQLSMALLINT identifier, SQLINTEGER& integer);
00072 static bool get_length(SQLSMALLINT handle_type, SQLHANDLE handle, SQLSMALLINT record, SQLSMALLINT identifier, SQLLEN& length);
00073
00074 private:
00075 SQLLEN f_affected_rows;
00076 diag_vector_t f_diag;
00077 };
00078
00079
00080
00081 }
00082
00083
00084 #endif // #ifndef ODBCPP_DIAG