00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <mpcl/text/string.hh>
00028 #include <mpcl/util/collection/map.hh>
00029 #include <uesqlc/defs.hh>
00030
00031
00033 namespace uesqlc
00034 {
00035
00036
00037
00038
00039
00041 static const char* _pkcSqlerrorDescription = "uesql: SQLERROR condition";
00042
00044 static const char* _pkcNotFoundDescription = "uesql: NOT FOUND condition";
00045
00046
00047
00048
00049
00050
00051
00052
00053 mpcl::util::collection::TMap<mpcl::text::TString, int> TSqlstateDescriptor::_tValueToIntMap;
00054 long int SQLCODE = 0;
00055 mpcl::text::TString SQLMESSAGE = "";
00056 mpcl::text::TString SQLSTATE = "00000";
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 namespace ambiguous_cursor_name
00067 {
00068 const char* pkcNO_SUBCLASS = "3C000";
00069 }
00070
00071 namespace cardinality_violation
00072 {
00073 const char* pkcNO_SUBCLASS = "21000";
00074 }
00075
00076 namespace connection_exception
00077 {
00078 const char* pkcNO_SUBCLASS = "08000";
00079 const char* pkcCONNECTION_DOES_NOT_EXIST = "08003";
00080 const char* pkcCONNECTION_FAILURE = "08006";
00081 const char* pkcCONNECTION_NAME_IN_USE = "08002";
00082 const char* pkcSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION = "08001";
00083 const char* pkcSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION = "08004";
00084 const char* pkcTRANSACTION_RESOLUTION_UNKNOWN = "08007";
00085 }
00086
00087 namespace data_exception
00088 {
00089 const char* pkcNO_SUBCLASS = "22000";
00090 const char* pkcCHARACTER_NOT_IN_REPERTOIRE = "22021";
00091 const char* pkcDATETIME_FIELD_OVERFLOW = "22008";
00092 const char* pkcDIVISION_BY_ZERO = "22012";
00093 const char* pkcERROR_IN_ASSIGNMENT = "22005";
00094 const char* pkcINDICATOR_OVERFLOW = "22022";
00095 const char* pkcINTERVAL_FIELD_OVERFLOW = "22015";
00096 const char* pkcINVALID_CHARACTER_VALUE_FOR_CAST = "22018";
00097 const char* pkcINVALID_DATETIME_FORMAT = "22007";
00098 const char* pkcINVALID_ESCAPE_CHARACTER = "22019";
00099 const char* pkcINVALID_ESCAPE_SEQUENCE = "22025";
00100 const char* pkcINVALID_PARAMETER_VALUE = "22023";
00101 const char* pkcINVALID_TIME_ZONE_DISPLACEMENT_VALUE = "22009";
00102 const char* pkcNULL_VALUE_NO_INDICATOR_PARAMETER = "22002";
00103 const char* pkcNUMERIC_VALUE_OUT_OF_RANGE = "22003";
00104 const char* pkcSTRING_DATA_LENGTH_MISMATCH = "22026";
00105 const char* pkcSTRING_DATA_RIGHT_TRUNCATION = "22001";
00106 const char* pkcSUBSTRING_ERROR = "22011";
00107 const char* pkcTRIM_ERROR = "22027";
00108 const char* pkcUNTERMINATED_C_STRING = "22024";
00109 }
00110
00111 namespace dependent_privilege_descriptors_still_exist
00112 {
00113 const char* pkcNO_SUBCLASS = "2B000";
00114 }
00115
00116 namespace dynamic_sql_error
00117 {
00118 const char* pkcNO_SUBCLASS = "07000";
00119 const char* pkcCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED = "07003";
00120 const char* pkcINVALID_DESCRIPTOR_COUNT = "07008";
00121 const char* pkcINVALID_DESCRIPTOR_INDEX = "07009";
00122 const char* pkcPREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION = "07005";
00123 const char* pkcRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION = "07006";
00124 const char* pkcUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC = "07001";
00125 const char* pkcUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC = "07002";
00126 const char* pkcUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS = "07004";
00127 const char* pkcUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS = "07007";
00128 }
00129
00130 namespace feature_not_supported
00131 {
00132 const char* pkcNO_SUBCLASS = "0A000";
00133 const char* pkcMULTIPLE_ENVIRONMENT_TRANSACTIONS = "0A001";
00134 }
00135
00136 namespace integrity_constraint_violation
00137 {
00138 const char* pkcNO_SUBCLASS = "23000";
00139 }
00140
00141 namespace invalid_authorization_specification
00142 {
00143 const char* pkcNO_SUBCLASS = "28000";
00144 }
00145
00146 namespace invalid_catalog_name
00147 {
00148 const char* pkcNO_SUBCLASS = "3D000";
00149 }
00150
00151 namespace invalid_character_set_name
00152 {
00153 const char* pkcNO_SUBCLASS = "2C000";
00154 }
00155
00156 namespace invalid_condition_number
00157 {
00158 const char* pkcNO_SUBCLASS = "35000";
00159 }
00160
00161 namespace invalid_connection_name
00162 {
00163 const char* pkcNO_SUBCLASS = "2E000";
00164 }
00165
00166 namespace invalid_cursor_name
00167 {
00168 const char* pkcNO_SUBCLASS = "34000";
00169 }
00170
00171 namespace invalid_cursor_state
00172 {
00173 const char* pkcNO_SUBCLASS = "24000";
00174 }
00175
00176 namespace invalid_schema_name
00177 {
00178 const char* pkcNO_SUBCLASS = "3F000";
00179 }
00180
00181 namespace invalid_sql_descriptor_name
00182 {
00183 const char* pkcNO_SUBCLASS = "33000";
00184 }
00185
00186 namespace invalid_sql_statement_name
00187 {
00188 const char* pkcNO_SUBCLASS = "26000";
00189 }
00190
00191 namespace invalid_transaction_state
00192 {
00193 const char* pkcNO_SUBCLASS = "25000";
00194 }
00195
00196 namespace invalid_transaction_termination
00197 {
00198 const char* pkcNO_SUBCLASS = "2D000";
00199 }
00200
00201 namespace no_data
00202 {
00203 const char* pkcNO_SUBCLASS = "02000";
00204 }
00205
00206 namespace remote_database_access
00207 {
00208 const char* pkcNO_SUBCLASS = "HZ000";
00209 }
00210
00211 namespace successful_completion
00212 {
00213 const char* pkcNO_SUBCLASS = "00000";
00214 }
00215
00216 namespace syntax_error_or_access_rule_violation
00217 {
00218 const char* pkcNO_SUBCLASS = "42000";
00219 }
00220
00221 namespace syntax_error_or_access_rule_violation_in_direct_statement
00222 {
00223 const char* pkcNO_SUBCLASS = "2A000";
00224 }
00225
00226 namespace syntax_error_or_access_rule_violation_in_dynamic_statement
00227 {
00228 const char* pkcNO_SUBCLASS = "37000";
00229 }
00230
00231 namespace transaction_rollback
00232 {
00233 const char* pkcNO_SUBCLASS = "40000";
00234 const char* pkcINTEGRITY_CONSTRAINT_VIOLATION = "40002";
00235 const char* pkcSERIALIZATION_FAILURE = "40001";
00236 const char* pkcSTATEMENT_COMPLETION_UNKNOWN = "40003";
00237 }
00238
00239 namespace triggered_data_change_violation
00240 {
00241 const char* pkcNO_SUBCLASS = "27000";
00242 }
00243
00244 namespace warning
00245 {
00246 const char* pkcNO_SUBCLASS = "01000";
00247 const char* pkcCURSOR_OPERATION_CONFLICT = "01001";
00248 const char* pkcDISCONNECT_ERROR = "01002";
00249 const char* pkcIMPLICIT_ZERO_BIT_PADDING = "01008";
00250 const char* pkcINSUFFICIENT_ITEM_DESCRIPTOR_AREAS = "01005";
00251 const char* pkcNULL_VALUE_ELIMINATED_IN_SET_FUNCTION = "01003";
00252 const char* pkcPRIVILEGE_NOT_GRANTED = "01007";
00253 const char* pkcPRIVILEGE_NOT_REVOKED = "01006";
00254 const char* pkcQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA = "0100A";
00255 const char* pkcSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA = "01009";
00256 const char* pkcSTRING_DATA_RIGHT_TRUNCATION = "01004";
00257 }
00258
00259 namespace with_check_option_violation
00260 {
00261 const char* pkcNO_SUBCLASS = "44000";
00262 }
00263
00264 }
00265
00266
00267
00268
00269
00270
00271 void uesqlc::TSqlstateDescriptor::
00272 _addCondition ( const char* pkcSQLSTATE ,
00273 int iVALUE )
00274 {
00275
00276 _tValueToIntMap.insert (std::make_pair (pkcSQLSTATE, iVALUE));
00277
00278 }
00279
00280
00281 void uesqlc::TSqlstateDescriptor::_initialize (void)
00282 {
00283
00284 if ( _tValueToIntMap.empty() )
00285 {
00286 _addCondition (ambiguous_cursor_name::pkcNO_SUBCLASS, ambiguous_cursor_name::eNO_SUBCLASS);
00287 _addCondition (cardinality_violation::pkcNO_SUBCLASS, cardinality_violation::eNO_SUBCLASS);
00288 _addCondition (connection_exception::pkcNO_SUBCLASS, connection_exception::eNO_SUBCLASS);
00289 _addCondition (connection_exception::pkcCONNECTION_DOES_NOT_EXIST, connection_exception::eCONNECTION_DOES_NOT_EXIST);
00290 _addCondition (connection_exception::pkcCONNECTION_FAILURE, connection_exception::eCONNECTION_FAILURE);
00291 _addCondition (connection_exception::pkcCONNECTION_NAME_IN_USE, connection_exception::eCONNECTION_NAME_IN_USE);
00292 _addCondition (connection_exception::pkcSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION, connection_exception::eSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION);
00293 _addCondition (connection_exception::pkcSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION, connection_exception::eSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION);
00294 _addCondition (connection_exception::pkcTRANSACTION_RESOLUTION_UNKNOWN, connection_exception::eTRANSACTION_RESOLUTION_UNKNOWN);
00295 _addCondition (data_exception::pkcNO_SUBCLASS, data_exception::eNO_SUBCLASS);
00296 _addCondition (data_exception::pkcCHARACTER_NOT_IN_REPERTOIRE, data_exception::eCHARACTER_NOT_IN_REPERTOIRE);
00297 _addCondition (data_exception::pkcDATETIME_FIELD_OVERFLOW, data_exception::eDATETIME_FIELD_OVERFLOW);
00298 _addCondition (data_exception::pkcDIVISION_BY_ZERO, data_exception::eDIVISION_BY_ZERO);
00299 _addCondition (data_exception::pkcERROR_IN_ASSIGNMENT, data_exception::eERROR_IN_ASSIGNMENT);
00300 _addCondition (data_exception::pkcINDICATOR_OVERFLOW, data_exception::eINDICATOR_OVERFLOW);
00301 _addCondition (data_exception::pkcINTERVAL_FIELD_OVERFLOW, data_exception::eINTERVAL_FIELD_OVERFLOW);
00302 _addCondition (data_exception::pkcINVALID_CHARACTER_VALUE_FOR_CAST, data_exception::eINVALID_CHARACTER_VALUE_FOR_CAST);
00303 _addCondition (data_exception::pkcINVALID_DATETIME_FORMAT, data_exception::eINVALID_DATETIME_FORMAT);
00304 _addCondition (data_exception::pkcINVALID_ESCAPE_CHARACTER, data_exception::eINVALID_ESCAPE_CHARACTER);
00305 _addCondition (data_exception::pkcINVALID_ESCAPE_SEQUENCE, data_exception::eINVALID_ESCAPE_SEQUENCE);
00306 _addCondition (data_exception::pkcINVALID_PARAMETER_VALUE, data_exception::eINVALID_PARAMETER_VALUE);
00307 _addCondition (data_exception::pkcINVALID_TIME_ZONE_DISPLACEMENT_VALUE, data_exception::eINVALID_TIME_ZONE_DISPLACEMENT_VALUE);
00308 _addCondition (data_exception::pkcNULL_VALUE_NO_INDICATOR_PARAMETER, data_exception::eNULL_VALUE_NO_INDICATOR_PARAMETER);
00309 _addCondition (data_exception::pkcNUMERIC_VALUE_OUT_OF_RANGE, data_exception::eNUMERIC_VALUE_OUT_OF_RANGE);
00310 _addCondition (data_exception::pkcSTRING_DATA_LENGTH_MISMATCH, data_exception::eSTRING_DATA_LENGTH_MISMATCH);
00311 _addCondition (data_exception::pkcSTRING_DATA_RIGHT_TRUNCATION, data_exception::eSTRING_DATA_RIGHT_TRUNCATION);
00312 _addCondition (data_exception::pkcSUBSTRING_ERROR, data_exception::eSUBSTRING_ERROR);
00313 _addCondition (data_exception::pkcTRIM_ERROR, data_exception::eTRIM_ERROR);
00314 _addCondition (data_exception::pkcUNTERMINATED_C_STRING, data_exception::eUNTERMINATED_C_STRING);
00315 _addCondition (dependent_privilege_descriptors_still_exist::pkcNO_SUBCLASS, dependent_privilege_descriptors_still_exist::eNO_SUBCLASS);
00316 _addCondition (dynamic_sql_error::pkcNO_SUBCLASS, dynamic_sql_error::eNO_SUBCLASS);
00317 _addCondition (dynamic_sql_error::pkcCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED, dynamic_sql_error::eCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED);
00318 _addCondition (dynamic_sql_error::pkcINVALID_DESCRIPTOR_COUNT, dynamic_sql_error::eINVALID_DESCRIPTOR_COUNT);
00319 _addCondition (dynamic_sql_error::pkcINVALID_DESCRIPTOR_INDEX, dynamic_sql_error::eINVALID_DESCRIPTOR_INDEX);
00320 _addCondition (dynamic_sql_error::pkcPREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION, dynamic_sql_error::ePREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION);
00321 _addCondition (dynamic_sql_error::pkcRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION, dynamic_sql_error::eRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION);
00322 _addCondition (dynamic_sql_error::pkcUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC, dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC);
00323 _addCondition (dynamic_sql_error::pkcUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC, dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC);
00324 _addCondition (dynamic_sql_error::pkcUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS, dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS);
00325 _addCondition (dynamic_sql_error::pkcUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS, dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS);
00326 _addCondition (feature_not_supported::pkcNO_SUBCLASS, feature_not_supported::eNO_SUBCLASS);
00327 _addCondition (feature_not_supported::pkcMULTIPLE_ENVIRONMENT_TRANSACTIONS, feature_not_supported::eMULTIPLE_ENVIRONMENT_TRANSACTIONS);
00328 _addCondition (integrity_constraint_violation::pkcNO_SUBCLASS, integrity_constraint_violation::eNO_SUBCLASS);
00329 _addCondition (invalid_authorization_specification::pkcNO_SUBCLASS, invalid_authorization_specification::eNO_SUBCLASS);
00330 _addCondition (invalid_catalog_name::pkcNO_SUBCLASS, invalid_catalog_name::eNO_SUBCLASS);
00331 _addCondition (invalid_character_set_name::pkcNO_SUBCLASS, invalid_character_set_name::eNO_SUBCLASS);
00332 _addCondition (invalid_condition_number::pkcNO_SUBCLASS, invalid_condition_number::eNO_SUBCLASS);
00333 _addCondition (invalid_connection_name::pkcNO_SUBCLASS, invalid_connection_name::eNO_SUBCLASS);
00334 _addCondition (invalid_cursor_name::pkcNO_SUBCLASS, invalid_cursor_name::eNO_SUBCLASS);
00335 _addCondition (invalid_cursor_state::pkcNO_SUBCLASS, invalid_cursor_state::eNO_SUBCLASS);
00336 _addCondition (invalid_schema_name::pkcNO_SUBCLASS, invalid_schema_name::eNO_SUBCLASS);
00337 _addCondition (invalid_sql_descriptor_name::pkcNO_SUBCLASS, invalid_sql_descriptor_name::eNO_SUBCLASS);
00338 _addCondition (invalid_sql_statement_name::pkcNO_SUBCLASS, invalid_sql_statement_name::eNO_SUBCLASS);
00339 _addCondition (invalid_transaction_state::pkcNO_SUBCLASS, invalid_transaction_state::eNO_SUBCLASS);
00340 _addCondition (invalid_transaction_termination::pkcNO_SUBCLASS, invalid_transaction_termination::eNO_SUBCLASS);
00341 _addCondition (no_data::pkcNO_SUBCLASS, no_data::eNO_SUBCLASS);
00342 _addCondition (remote_database_access::pkcNO_SUBCLASS, remote_database_access::eNO_SUBCLASS);
00343 _addCondition (successful_completion::pkcNO_SUBCLASS, successful_completion::eNO_SUBCLASS);
00344 _addCondition (syntax_error_or_access_rule_violation::pkcNO_SUBCLASS, syntax_error_or_access_rule_violation::eNO_SUBCLASS);
00345 _addCondition (syntax_error_or_access_rule_violation_in_direct_statement::pkcNO_SUBCLASS, syntax_error_or_access_rule_violation_in_direct_statement::eNO_SUBCLASS);
00346 _addCondition (syntax_error_or_access_rule_violation_in_dynamic_statement::pkcNO_SUBCLASS, syntax_error_or_access_rule_violation_in_dynamic_statement::eNO_SUBCLASS);
00347 _addCondition (transaction_rollback::pkcNO_SUBCLASS, transaction_rollback::eNO_SUBCLASS);
00348 _addCondition (transaction_rollback::pkcINTEGRITY_CONSTRAINT_VIOLATION, transaction_rollback::eINTEGRITY_CONSTRAINT_VIOLATION);
00349 _addCondition (transaction_rollback::pkcSERIALIZATION_FAILURE, transaction_rollback::eSERIALIZATION_FAILURE);
00350 _addCondition (transaction_rollback::pkcSTATEMENT_COMPLETION_UNKNOWN, transaction_rollback::eSTATEMENT_COMPLETION_UNKNOWN);
00351 _addCondition (triggered_data_change_violation::pkcNO_SUBCLASS, triggered_data_change_violation::eNO_SUBCLASS);
00352 _addCondition (warning::pkcNO_SUBCLASS, warning::eNO_SUBCLASS);
00353 _addCondition (warning::pkcCURSOR_OPERATION_CONFLICT, warning::eCURSOR_OPERATION_CONFLICT);
00354 _addCondition (warning::pkcDISCONNECT_ERROR, warning::eDISCONNECT_ERROR);
00355 _addCondition (warning::pkcIMPLICIT_ZERO_BIT_PADDING, warning::eIMPLICIT_ZERO_BIT_PADDING);
00356 _addCondition (warning::pkcINSUFFICIENT_ITEM_DESCRIPTOR_AREAS, warning::eINSUFFICIENT_ITEM_DESCRIPTOR_AREAS);
00357 _addCondition (warning::pkcNULL_VALUE_ELIMINATED_IN_SET_FUNCTION, warning::eNULL_VALUE_ELIMINATED_IN_SET_FUNCTION);
00358 _addCondition (warning::pkcPRIVILEGE_NOT_GRANTED, warning::ePRIVILEGE_NOT_GRANTED);
00359 _addCondition (warning::pkcPRIVILEGE_NOT_REVOKED, warning::ePRIVILEGE_NOT_REVOKED);
00360 _addCondition (warning::pkcQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA, warning::eQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA);
00361 _addCondition (warning::pkcSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA, warning::eSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA);
00362 _addCondition (warning::pkcSTRING_DATA_RIGHT_TRUNCATION, warning::eSTRING_DATA_RIGHT_TRUNCATION);
00363 _addCondition (with_check_option_violation::pkcNO_SUBCLASS, with_check_option_violation::eNO_SUBCLASS);
00364 }
00365
00366 }
00367
00368
00369
00370
00371
00372
00373 const char* uesqlc::TSqlstateDescriptor::getClassValue (const char* pkcSQLSTATE) const
00374 {
00375
00376 const char* pkcClass = NULL;
00377
00378 switch (getUniqueValue (pkcSQLSTATE))
00379 {
00380 case ambiguous_cursor_name::eNO_SUBCLASS:
00381 {
00382 pkcClass = "ambiguous cursor name";
00383 break;
00384 }
00385 case cardinality_violation::eNO_SUBCLASS:
00386 {
00387 pkcClass = "cardinality violation";
00388 break;
00389 }
00390 case connection_exception::eNO_SUBCLASS:
00391 case connection_exception::eCONNECTION_DOES_NOT_EXIST:
00392 case connection_exception::eCONNECTION_FAILURE:
00393 case connection_exception::eCONNECTION_NAME_IN_USE:
00394 case connection_exception::eSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION:
00395 case connection_exception::eSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION:
00396 case connection_exception::eTRANSACTION_RESOLUTION_UNKNOWN:
00397 {
00398 pkcClass = "connection exception";
00399 break;
00400 }
00401 case data_exception::eNO_SUBCLASS:
00402 case data_exception::eCHARACTER_NOT_IN_REPERTOIRE:
00403 case data_exception::eDATETIME_FIELD_OVERFLOW:
00404 case data_exception::eDIVISION_BY_ZERO:
00405 case data_exception::eERROR_IN_ASSIGNMENT:
00406 case data_exception::eINDICATOR_OVERFLOW:
00407 case data_exception::eINTERVAL_FIELD_OVERFLOW:
00408 case data_exception::eINVALID_CHARACTER_VALUE_FOR_CAST:
00409 case data_exception::eINVALID_DATETIME_FORMAT:
00410 case data_exception::eINVALID_ESCAPE_CHARACTER:
00411 case data_exception::eINVALID_ESCAPE_SEQUENCE:
00412 case data_exception::eINVALID_PARAMETER_VALUE:
00413 case data_exception::eINVALID_TIME_ZONE_DISPLACEMENT_VALUE:
00414 case data_exception::eNULL_VALUE_NO_INDICATOR_PARAMETER:
00415 case data_exception::eNUMERIC_VALUE_OUT_OF_RANGE:
00416 case data_exception::eSTRING_DATA_LENGTH_MISMATCH:
00417 case data_exception::eSTRING_DATA_RIGHT_TRUNCATION:
00418 case data_exception::eSUBSTRING_ERROR:
00419 case data_exception::eTRIM_ERROR:
00420 case data_exception::eUNTERMINATED_C_STRING:
00421 {
00422 pkcClass = "data exception";
00423 break;
00424 }
00425 case dependent_privilege_descriptors_still_exist::eNO_SUBCLASS:
00426 {
00427 pkcClass = "dependent privilege descriptors still exist";
00428 break;
00429 }
00430 case dynamic_sql_error::eNO_SUBCLASS:
00431 case dynamic_sql_error::eCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED:
00432 case dynamic_sql_error::eINVALID_DESCRIPTOR_COUNT:
00433 case dynamic_sql_error::eINVALID_DESCRIPTOR_INDEX:
00434 case dynamic_sql_error::ePREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION:
00435 case dynamic_sql_error::eRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION:
00436 case dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC:
00437 case dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC:
00438 case dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS:
00439 case dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS:
00440 {
00441 pkcClass = "dynamic SQL error";
00442 break;
00443 }
00444 case feature_not_supported::eNO_SUBCLASS:
00445 case feature_not_supported::eMULTIPLE_ENVIRONMENT_TRANSACTIONS:
00446 {
00447 pkcClass = "feature not supported";
00448 break;
00449 }
00450 case integrity_constraint_violation::eNO_SUBCLASS:
00451 {
00452 pkcClass = "integrity constraint violation";
00453 break;
00454 }
00455 case invalid_authorization_specification::eNO_SUBCLASS:
00456 {
00457 pkcClass = "invalid authorization specification";
00458 break;
00459 }
00460 case invalid_catalog_name::eNO_SUBCLASS:
00461 {
00462 pkcClass = "invalid catalog name";
00463 break;
00464 }
00465 case invalid_character_set_name::eNO_SUBCLASS:
00466 {
00467 pkcClass = "invalid character set name";
00468 break;
00469 }
00470 case invalid_condition_number::eNO_SUBCLASS:
00471 {
00472 pkcClass = "invalid condition number";
00473 break;
00474 }
00475 case invalid_connection_name::eNO_SUBCLASS:
00476 {
00477 pkcClass = "invalid connection name";
00478 break;
00479 }
00480 case invalid_cursor_name::eNO_SUBCLASS:
00481 {
00482 pkcClass = "invalid cursor name";
00483 break;
00484 }
00485 case invalid_cursor_state::eNO_SUBCLASS:
00486 {
00487 pkcClass = "invalid cursor state";
00488 break;
00489 }
00490 case invalid_schema_name::eNO_SUBCLASS:
00491 {
00492 pkcClass = "invalid schema name";
00493 break;
00494 }
00495 case invalid_sql_descriptor_name::eNO_SUBCLASS:
00496 {
00497 pkcClass = "invalid SQL descriptor name";
00498 break;
00499 }
00500 case invalid_sql_statement_name::eNO_SUBCLASS:
00501 {
00502 pkcClass = "invalid SQL statement name";
00503 break;
00504 }
00505 case invalid_transaction_state::eNO_SUBCLASS:
00506 {
00507 pkcClass = "invalid transaction state";
00508 break;
00509 }
00510 case invalid_transaction_termination::eNO_SUBCLASS:
00511 {
00512 pkcClass = "invalid transaction termination";
00513 break;
00514 }
00515 case no_data::eNO_SUBCLASS:
00516 {
00517 pkcClass = "no data";
00518 break;
00519 }
00520 case remote_database_access::eNO_SUBCLASS:
00521 {
00522 pkcClass = "remote database access";
00523 break;
00524 }
00525 case successful_completion::eNO_SUBCLASS:
00526 {
00527 pkcClass = "successful completion";
00528 break;
00529 }
00530 case syntax_error_or_access_rule_violation::eNO_SUBCLASS:
00531 {
00532 pkcClass = "syntax error or access rule violation";
00533 break;
00534 }
00535 case syntax_error_or_access_rule_violation_in_direct_statement::eNO_SUBCLASS:
00536 {
00537 pkcClass = "syntax error or access rule violation in direct statement";
00538 break;
00539 }
00540 case syntax_error_or_access_rule_violation_in_dynamic_statement::eNO_SUBCLASS:
00541 {
00542 pkcClass = "syntax error or access rule violation in dynamic statement";
00543 break;
00544 }
00545 case transaction_rollback::eNO_SUBCLASS:
00546 case transaction_rollback::eINTEGRITY_CONSTRAINT_VIOLATION:
00547 case transaction_rollback::eSERIALIZATION_FAILURE:
00548 case transaction_rollback::eSTATEMENT_COMPLETION_UNKNOWN:
00549 {
00550 pkcClass = "transaction rollback";
00551 break;
00552 }
00553 case triggered_data_change_violation::eNO_SUBCLASS:
00554 {
00555 pkcClass = "triggered data change violation";
00556 break;
00557 }
00558 case warning::eNO_SUBCLASS:
00559 case warning::eCURSOR_OPERATION_CONFLICT:
00560 case warning::eDISCONNECT_ERROR:
00561 case warning::eIMPLICIT_ZERO_BIT_PADDING:
00562 case warning::eINSUFFICIENT_ITEM_DESCRIPTOR_AREAS:
00563 case warning::eNULL_VALUE_ELIMINATED_IN_SET_FUNCTION:
00564 case warning::ePRIVILEGE_NOT_GRANTED:
00565 case warning::ePRIVILEGE_NOT_REVOKED:
00566 case warning::eQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA:
00567 case warning::eSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA:
00568 case warning::eSTRING_DATA_RIGHT_TRUNCATION:
00569 {
00570 pkcClass = "warning";
00571 break;
00572 }
00573 case with_check_option_violation::eNO_SUBCLASS:
00574 {
00575 pkcClass = "with check option violation";
00576 break;
00577 }
00578 default:
00579 {
00580 pkcClass = "unknown code";
00581 }
00582 }
00583 return pkcClass;
00584
00585 }
00586
00587
00588 mpcl::text::TString uesqlc::TSqlstateDescriptor::
00589 getDescription (const char* pkcSQLSTATE) const
00590 {
00591
00592 mpcl::text::TString yDescription (getClassValue (pkcSQLSTATE));
00593
00594 yDescription.append (": ");
00595 yDescription.append (getSubclassValue (pkcSQLSTATE));
00596 if ( !uesqlc::SQLMESSAGE.empty() )
00597 {
00598 yDescription.append (" (");
00599 yDescription.append (uesqlc::SQLMESSAGE);
00600 yDescription.append (")");
00601 }
00602 return yDescription;
00603
00604 }
00605
00606
00607 const char* uesqlc::TSqlstateDescriptor::
00608 getSubclassValue (const char* pkcSQLSTATE) const
00609 {
00610
00611 const char* pkcSubclass = NULL;
00612
00613 switch (getUniqueValue (pkcSQLSTATE))
00614 {
00615 case ambiguous_cursor_name::eNO_SUBCLASS:
00616 case cardinality_violation::eNO_SUBCLASS:
00617 case connection_exception::eNO_SUBCLASS:
00618 case data_exception::eNO_SUBCLASS:
00619 case dependent_privilege_descriptors_still_exist::eNO_SUBCLASS:
00620 case dynamic_sql_error::eNO_SUBCLASS:
00621 case feature_not_supported::eNO_SUBCLASS:
00622 case integrity_constraint_violation::eNO_SUBCLASS:
00623 case invalid_authorization_specification::eNO_SUBCLASS:
00624 case invalid_catalog_name::eNO_SUBCLASS:
00625 case invalid_character_set_name::eNO_SUBCLASS:
00626 case invalid_condition_number::eNO_SUBCLASS:
00627 case invalid_connection_name::eNO_SUBCLASS:
00628 case invalid_cursor_name::eNO_SUBCLASS:
00629 case invalid_cursor_state::eNO_SUBCLASS:
00630 case invalid_schema_name::eNO_SUBCLASS:
00631 case invalid_sql_descriptor_name::eNO_SUBCLASS:
00632 case invalid_sql_statement_name::eNO_SUBCLASS:
00633 case invalid_transaction_state::eNO_SUBCLASS:
00634 case invalid_transaction_termination::eNO_SUBCLASS:
00635 case no_data::eNO_SUBCLASS:
00636 case remote_database_access::eNO_SUBCLASS:
00637 case successful_completion::eNO_SUBCLASS:
00638 case syntax_error_or_access_rule_violation::eNO_SUBCLASS:
00639 case syntax_error_or_access_rule_violation_in_direct_statement::eNO_SUBCLASS:
00640 case syntax_error_or_access_rule_violation_in_dynamic_statement::eNO_SUBCLASS:
00641 case transaction_rollback::eNO_SUBCLASS:
00642 case triggered_data_change_violation::eNO_SUBCLASS:
00643 case warning::eNO_SUBCLASS:
00644 case with_check_option_violation::eNO_SUBCLASS:
00645 {
00646 pkcSubclass = "(no subclass)";
00647 break;
00648 }
00649 case connection_exception::eCONNECTION_DOES_NOT_EXIST:
00650 {
00651 pkcSubclass = "connection does not exist";
00652 break;
00653 }
00654 case connection_exception::eCONNECTION_FAILURE:
00655 {
00656 pkcSubclass = "connection failure";
00657 break;
00658 }
00659 case connection_exception::eCONNECTION_NAME_IN_USE:
00660 {
00661 pkcSubclass = "connection name in use";
00662 break;
00663 }
00664 case connection_exception::eSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION:
00665 {
00666 pkcSubclass = "SQL-client unable to establish SQL-connection";
00667 break;
00668 }
00669 case connection_exception::eSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION:
00670 {
00671 pkcSubclass = "SQL-server rejected establishment of SQL-connection";
00672 break;
00673 }
00674 case connection_exception::eTRANSACTION_RESOLUTION_UNKNOWN:
00675 {
00676 pkcSubclass = "transaction resolution unknown";
00677 break;
00678 }
00679 case data_exception::eCHARACTER_NOT_IN_REPERTOIRE:
00680 {
00681 pkcSubclass = "character not in repertoire";
00682 break;
00683 }
00684 case data_exception::eDATETIME_FIELD_OVERFLOW:
00685 {
00686 pkcSubclass = "datetime field overflow";
00687 break;
00688 }
00689 case data_exception::eDIVISION_BY_ZERO:
00690 {
00691 pkcSubclass = "division by zero";
00692 break;
00693 }
00694 case data_exception::eERROR_IN_ASSIGNMENT:
00695 {
00696 pkcSubclass = "error in assignment";
00697 break;
00698 }
00699 case data_exception::eINDICATOR_OVERFLOW:
00700 {
00701 pkcSubclass = "indicator overflow";
00702 break;
00703 }
00704 case data_exception::eINTERVAL_FIELD_OVERFLOW:
00705 {
00706 pkcSubclass = "interval field overflow";
00707 break;
00708 }
00709 case data_exception::eINVALID_CHARACTER_VALUE_FOR_CAST:
00710 {
00711 pkcSubclass = "invalid character value for cast";
00712 break;
00713 }
00714 case data_exception::eINVALID_DATETIME_FORMAT:
00715 {
00716 pkcSubclass = "invalid datetime format";
00717 break;
00718 }
00719 case data_exception::eINVALID_ESCAPE_CHARACTER:
00720 {
00721 pkcSubclass = "invalid escape character";
00722 break;
00723 }
00724 case data_exception::eINVALID_ESCAPE_SEQUENCE:
00725 {
00726 pkcSubclass = "invalid escape sequence";
00727 break;
00728 }
00729 case data_exception::eINVALID_PARAMETER_VALUE:
00730 {
00731 pkcSubclass = "invalid parameter value";
00732 break;
00733 }
00734 case data_exception::eINVALID_TIME_ZONE_DISPLACEMENT_VALUE:
00735 {
00736 pkcSubclass = "invalid time zone displacement value";
00737 break;
00738 }
00739 case data_exception::eNULL_VALUE_NO_INDICATOR_PARAMETER:
00740 {
00741 pkcSubclass = "null value, no indicator parameter";
00742 break;
00743 }
00744 case data_exception::eNUMERIC_VALUE_OUT_OF_RANGE:
00745 {
00746 pkcSubclass = "numeric value out of range";
00747 break;
00748 }
00749 case data_exception::eSTRING_DATA_LENGTH_MISMATCH:
00750 {
00751 pkcSubclass = "string data, length mismatch";
00752 break;
00753 }
00754 case data_exception::eSTRING_DATA_RIGHT_TRUNCATION:
00755 {
00756 pkcSubclass = "string data, right truncation";
00757 break;
00758 }
00759 case data_exception::eSUBSTRING_ERROR:
00760 {
00761 pkcSubclass = "substring error";
00762 break;
00763 }
00764 case data_exception::eTRIM_ERROR:
00765 {
00766 pkcSubclass = "trim error";
00767 break;
00768 }
00769 case data_exception::eUNTERMINATED_C_STRING:
00770 {
00771 pkcSubclass = "unterminated C string";
00772 break;
00773 }
00774 case dynamic_sql_error::eCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED:
00775 {
00776 pkcSubclass = "cursor specification cannot be executed";
00777 break;
00778 }
00779 case dynamic_sql_error::eINVALID_DESCRIPTOR_COUNT:
00780 {
00781 pkcSubclass = "invalid descriptor count";
00782 break;
00783 }
00784 case dynamic_sql_error::eINVALID_DESCRIPTOR_INDEX:
00785 {
00786 pkcSubclass = "invalid descriptor index";
00787 break;
00788 }
00789 case dynamic_sql_error::ePREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION:
00790 {
00791 pkcSubclass = "prepared statement not a cursor specification";
00792 break;
00793 }
00794 case dynamic_sql_error::eRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION:
00795 {
00796 pkcSubclass = "restricted data type attribute violation";
00797 break;
00798 }
00799 case dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC:
00800 {
00801 pkcSubclass = "using clause does not match dynamic parameter specifications";
00802 break;
00803 }
00804 case dynamic_sql_error::eUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC:
00805 {
00806 pkcSubclass = "using clause does not match target specifications";
00807 break;
00808 }
00809 case dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS:
00810 {
00811 pkcSubclass = "using clause required for dynamic parameters";
00812 break;
00813 }
00814 case dynamic_sql_error::eUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS:
00815 {
00816 pkcSubclass = "using clause required for result fields";
00817 break;
00818 }
00819 case feature_not_supported::eMULTIPLE_ENVIRONMENT_TRANSACTIONS:
00820 {
00821 pkcSubclass = "multiple environment transactions";
00822 break;
00823 }
00824 case transaction_rollback::eINTEGRITY_CONSTRAINT_VIOLATION:
00825 {
00826 pkcSubclass = "integrity constraint violation";
00827 break;
00828 }
00829 case transaction_rollback::eSERIALIZATION_FAILURE:
00830 {
00831 pkcSubclass = "serialization failure";
00832 break;
00833 }
00834 case transaction_rollback::eSTATEMENT_COMPLETION_UNKNOWN:
00835 {
00836 pkcSubclass = "statement completion unknown";
00837 break;
00838 }
00839 case warning::eCURSOR_OPERATION_CONFLICT:
00840 {
00841 pkcSubclass = "cursor operation conflict";
00842 break;
00843 }
00844 case warning::eDISCONNECT_ERROR:
00845 {
00846 pkcSubclass = "disconnect error";
00847 break;
00848 }
00849 case warning::eIMPLICIT_ZERO_BIT_PADDING:
00850 {
00851 pkcSubclass = "implicit zero-bit padding";
00852 break;
00853 }
00854 case warning::eINSUFFICIENT_ITEM_DESCRIPTOR_AREAS:
00855 {
00856 pkcSubclass = "insufficient item descriptor areas";
00857 break;
00858 }
00859 case warning::eNULL_VALUE_ELIMINATED_IN_SET_FUNCTION:
00860 {
00861 pkcSubclass = "null value eliminated in set function";
00862 break;
00863 }
00864 case warning::ePRIVILEGE_NOT_GRANTED:
00865 {
00866 pkcSubclass = "privilege not granted";
00867 break;
00868 }
00869 case warning::ePRIVILEGE_NOT_REVOKED:
00870 {
00871 pkcSubclass = "privilege not revoked";
00872 break;
00873 }
00874 case warning::eQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA:
00875 {
00876 pkcSubclass = "query expression too long for information schema";
00877 break;
00878 }
00879 case warning::eSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA:
00880 {
00881 pkcSubclass = "search condition too long for information schema";
00882 break;
00883 }
00884 case warning::eSTRING_DATA_RIGHT_TRUNCATION:
00885 {
00886 pkcSubclass = "string data, right truncation";
00887 break;
00888 }
00889 default:
00890 {
00891 pkcSubclass = "unknown code";
00892 }
00893 }
00894 return pkcSubclass;
00895
00896 }
00897
00898
00899 uesqlc::TNotFoundException::
00900 TNotFoundException ( const char* pkcFILE_NAME ,
00901 const int kiLINE_NUMBER ) :
00902 mpcl::TException ( _pkcNotFoundDescription ,
00903 "" ,
00904 pkcFILE_NAME ,
00905 kiLINE_NUMBER ) ,
00906 mpcl::TWarningException () ,
00907 TSqlstateDescriptor ()
00908 {
00909
00910 yRationale = getDescription (uesqlc::SQLSTATE.c_str());
00911
00912 }
00913
00914
00915 uesqlc::TSqlerrorException::
00916 TSqlerrorException ( const char* pkcFILE_NAME ,
00917 const int kiLINE_NUMBER ) :
00918 mpcl::TException ( _pkcSqlerrorDescription ,
00919 "" ,
00920 pkcFILE_NAME ,
00921 kiLINE_NUMBER ) ,
00922 mpcl::TErrorException () ,
00923 TSqlstateDescriptor ()
00924 {
00925
00926 yRationale = getDescription (uesqlc::SQLSTATE.c_str());
00927
00928 }
00929
00930
00931
00932
00933
00934
00935 const std::string uesqlc::TSqlerrorException::
00936 what (void) const
00937 {
00938
00939 std::string yDescription;
00940
00941 if ( !yFileName.empty() )
00942 {
00943 yDescription = mpcl::text::Format ( "%s:%d:" ,
00944 yFileName.c_str() ,
00945 iLineNumber );
00946 }
00947 yDescription.append (ySynopsis);
00948 yDescription.append ("; ");
00949 if ( yRationale.empty() )
00950 {
00951 yDescription.append (getDescription (SQLSTATE.c_str()));
00952 }
00953 else
00954 {
00955 yDescription.append (yRationale);
00956 }
00957 return yDescription;
00958
00959 }
00960
00961
00962 const std::string uesqlc::TNotFoundException::
00963 what (void) const
00964 {
00965
00966 std::string yDescription;
00967
00968 if ( !yFileName.empty() )
00969 {
00970 yDescription = mpcl::text::Format ( "%s:%d:" ,
00971 yFileName.c_str() ,
00972 iLineNumber );
00973 }
00974 yDescription.append (ySynopsis);
00975 yDescription.append ("; ");
00976 if ( yRationale.empty() )
00977 {
00978 yDescription.append (getDescription (SQLSTATE.c_str()));
00979 }
00980 else
00981 {
00982 yDescription.append (yRationale);
00983 }
00984 return yDescription;
00985
00986 }
00987
00988
00989
00990
00991
00992
00993 uesqlc::TString uesqlc::
00994 ComposeSchemaLocation ( const std::string& rkyHOST_NAME ,
00995 const std::string& rkySCHEMA_NAME )
00996 {
00997
00998 return mpcl::text::Format ( "%s/%s" ,
00999 rkyHOST_NAME.c_str() ,
01000 rkySCHEMA_NAME.c_str() );
01001
01002 }
01003
01004
01005 uesqlc::TString uesqlc::
01006 ComposeUserLogin ( const std::string& rkyUSER_NAME ,
01007 const std::string& rkyUSER_PASSWORD )
01008 {
01009
01010 return mpcl::text::Format ( "%s/%s" ,
01011 rkyUSER_NAME.c_str() ,
01012 rkyUSER_PASSWORD.c_str() );
01013
01014 }
01015
01016
01017 uesqlc::TString uesqlc::ToString (bool gVALUE)
01018 {
01019
01020 return mpcl::text::Format ("%d", (int) gVALUE);
01021
01022 }
01023
01024
01025 uesqlc::TString uesqlc::ToString (long double ldNUMBER)
01026 {
01027
01028 return mpcl::text::Format ("%Lf", ldNUMBER);
01029
01030 }
01031
01032
01033 uesqlc::TString uesqlc::ToString (long int liNUMBER)
01034 {
01035
01036 return mpcl::text::Format ("%ld", liNUMBER);
01037
01038 }
01039
01040
01041 uesqlc::TString uesqlc::ToString (long unsigned int luiNUMBER)
01042 {
01043
01044 return mpcl::text::Format ("%lu", luiNUMBER);
01045
01046 }