OTL 4.0, OTL exception class
OTL exception class
This class is used by the OTL functions to raise exceptions. In case if
an OTL function receives a non-zero error code from the underlying
database
API, the OTL function raises an exception of the otl_exception type. A
raised otl_exception may be a database error or an OTL
defined exception.
class otl_exception {
public:
- First 2047 characters of the text of the SQL statement in which
the
otl_exception
was raised.
char stm_text[2048 or OTL_EXCEPTION_STM_TEXT_SIZE];
- In case if the OTL defined exception "Incompatible
data types in stream operation" is raised, the var_info
field
is filled out with variable specific information: bind variable name /
select output column number, its datatype and the datatype of the
parameter
of the operator >> or operator <<.
char var_info[256];
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
OTL_UNICODE_CHAR_TYPE msg[1000];
#else
unsigned char msg[1000];
#endif
- The code field contains a database error code or a code
of an OTL
defined exception
int code;
- The sqlstate field is used in OTL 4.0/ODBC and in OTL
4.0/DB2-CLI
only. It is always empty in OTL 4.0/OCIx. In OTL 4.0/ODBC or
OTL/DB2-CLI,
the field contains the sqlstate information, the way it is defined in
ODBC.
For more detail, see the ODBC Programmer's Guide, the DB2 CLI
Programmer's
Guide.
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
OTL_UNICODE_CHAR_TYPE sqlstate[1000];
#else
unsigned char sqlstate[1000];
#endif
Extended fields, containing all ODBC /
DB2-CLI diagnostic
records, retrieved by the ODBC/DB2-CLI SQLGetDiagRec() function.
otl_exception
usually retrieves only the first diagnostic record and populates the msg,
code, and sqlstate fields with it. In some cases,
though,
multiple diagnostic records can be retrieved. In these cases, the
extended
fields get populated with the diagnostic records. arr_len
conatins
the size of the xxx_arr[] fields. The xxx_arr[] fields get allocated
and
deallocated dynamically, if the arr_len>0. msg_arr[] contains
the
diagnostic messages, sqlstate_arr[] --the SQLSTATE
information,
and code_arr[] -- the error codes. msg, code,
and sqlstate get always populated with the first diagnostic
record.
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
int arr_len;
OTL_UNICODE_CHAR_TYPE* msg_arr[];
OTL_UNICODE_CHAR_TYPE* sqlstate_arr[];
int code_arr[];
#else
int arr_len;
char* msg_arr[];
char* sqlstate_arr[];
int code_arr[];
#endif
- SQL Statement Parse Error Offset. Avalilable for OTL/OCIx only.
#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
int error_offset;
#endif
enum{disabled=0,enabled=1};
}; // end of otl_exception
Prev NextContents
Go Home
Copyright © 1996, 2007, Sergei Kuchin, email: skuchin@ispwest.com,
skuchin@gmail.com
.
Permission to use, copy, modify and redistribute this document
for
any purpose is hereby granted without fee, provided that the above
copyright
notice appear in all copies.