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:
Function / data member
Description
char stm_text[2048 or OTL_EXCEPTION_STM_TEXT_SIZE];
First 2047 characters of the text of the SQL statement in which the otl_exception was raised. When the stream label (sqlstm_label parameter in otl_stream constructors or open() function ) is defined  (!= NULL), it's used to populate the stm_text data member instead of the SQL statement text.
char var_info[256];
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 <<.
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
SQLWCHAR msg[1000];
#else
     unsigned char msg[1000];
#endif
The msg field contains a database error message or a message of an OTL defined exception
int code; The code field contains a database error code or a code of an OTL defined exception
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
SQLWCHAR
sqlstate[1000];
#else
     unsigned char sqlstate[1000];
#endif
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_EXTENDED_EXCEPTION)
#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
   int arr_len;
     SQLWCHAR* msg_arr[];
     SQLWCHAR* sqlstate_arr[];
     int code_arr[];
#else
   int arr_len;
     char* msg_arr[];
     char* sqlstate_arr[];
     int code_arr[];
#endif
#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 contains 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_EXCEPTION_ENABLE_ERROR_OFFSET)
    int error_offset;
#endif
SQL Statement Parse Error Offset. Available for OTL/OCIx only.
enum{disabled=0,enabled=1};
This enum defines two constants which may be used in execution of constant SQL statements

}; // end of otl_exception

Prev NextContents Go Home

Copyright © 1996-2023, Sergei Kuchin, email: skuchin@gmail.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. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.