utility.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 Maciej Sobczak, Stephen Hutton, David Courtney
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 //
7 
8 #ifndef SOCI_UTILITY_H_INCLUDED
9 #define SOCI_UTILITY_H_INCLUDED
10 
11 #include "soci-backend.h"
12 #include <sstream>
13 
14 namespace soci
15 {
16 
17 inline void throw_odbc_error(SQLSMALLINT htype, SQLHANDLE hndl, char const * msg)
18 {
19  SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1];
20  SQLCHAR sqlstate[SQL_SQLSTATE_SIZE + 1];
21  SQLINTEGER sqlcode;
22  SQLSMALLINT length, i;
23 
24  std::stringstream ss;
25 
26  i = 1;
27 
28  /* get multiple field settings of diagnostic record */
29  while (SQLGetDiagRecA(htype,
30  hndl,
31  i,
32  sqlstate,
33  &sqlcode,
34  message,
35  SQL_MAX_MESSAGE_LENGTH + 1,
36  &length) == SQL_SUCCESS)
37  {
38  ss << std::endl << "SOCI ODBC Error: " << msg << std::endl
39  << "SQLSTATE = " << sqlstate << std::endl
40  << "Native Error Code = " << sqlcode << std::endl
41  << message << std::endl;
42  ++i;
43  }
44 
45  throw soci_error(ss.str());
46 }
47 
48 inline bool is_odbc_error(SQLRETURN rc)
49 {
50  if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO)
51  {
52  return true;
53  }
54  else
55  {
56  return false;
57  }
58 }
59 
60 }
61 
62 #endif // SOCI_UTILITY_H_INCLUDED
bool is_odbc_error(SQLRETURN rc)
Definition: soci-odbc.h:399
void throw_odbc_error(SQLSMALLINT htype, SQLHANDLE hndl, char const *msg)
Definition: utility.h:17


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:41