File: DB2Exception.cc

package info (click to toggle)
pdns 3.1-4.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,356 kB
  • sloc: cpp: 42,003; ansic: 22,326; sh: 18,273; sql: 618; makefile: 590; yacc: 222; lex: 133; perl: 52
file content (44 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// $Id: DB2Exception.cc 477 2005-09-03 18:15:37Z ahu $

#include "DB2Exception.hh"

DB2Exception::DB2Exception(SQLRETURN inError)
   : mError(inError), mHandle(SQL_NULL_HANDLE), mErrorIndex(1)
{
}
      
DB2Exception::DB2Exception(SQLRETURN inError, SQLSMALLINT inHandleType, SQLHANDLE inHandle)
   : mError(inError), mHandle(inHandle), mHandleType(inHandleType), mErrorIndex(1)
{
}

SQLRETURN DB2Exception::GetError()
{
   return mError;
}
      
bool DB2Exception::GetNextSqlError(int& outNativeError, string& outSqlState, string& outSqlMessage)
{
   SQLCHAR     message[SQL_MAX_MESSAGE_LENGTH + 1];
   SQLCHAR     sqlstate[SQL_SQLSTATE_SIZE + 1];
   SQLINTEGER  sqlcode;
   SQLSMALLINT length;
   
   bool theResult = false;
   
   if (mHandle != SQL_NULL_HANDLE)
   {
      SQLRETURN theError = SQLGetDiagRec(mHandleType, mHandle, mErrorIndex, sqlstate, &sqlcode, message, SQL_MAX_MESSAGE_LENGTH + 1, &length);
      if (theError == SQL_SUCCESS)
      {
         outNativeError = sqlcode;
         outSqlState = (const char*) sqlstate;
         outSqlMessage = (const char*) message;
         
         mErrorIndex++;
         theResult = true;
      }
   }
   
   return theResult;
}