Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

defs.hh

00001 /*
00002 *  Name:      defs.hh
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   UESQLC definitions
00005 *  Date:      $Date: 2003/10/06 13:21:35 $
00006 *  Revision:  $Revision: 1.1 $
00007 *
00008 *  Copyright (C) 1996-2002  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00009 *
00010 *  This program is free software; you can redistribute it and/or modify
00011 *  it under the terms of the GNU General Public License as published by
00012 *  the Free Software Foundation; either version 2 of the License, or
00013 *  (at your option) any later version.
00014 *
00015 *  This program is distributed in the hope that it will be useful,
00016 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 *  GNU General Public License for more details.
00019 *
00020 *  You should have received a copy of the GNU General Public License
00021 *  along with this program; if not, write to the Free Software
00022 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 *  MA 02111-1307, USA.
00024 */
00025 
00026 #ifndef _UESQL_DEFS__
00027 #define _UESQL_DEFS__
00028 
00029 #include <mpcl/error_exception.hh>
00030 #include <mpcl/exceptions.hh>
00031 #include <mpcl/text/string.hh>
00032 #include <mpcl/util/collection/map.hh>
00033 #include <mpcl/warning_exception.hh>
00034 #include <uesqlc/date.hh>
00035 #include <uesqlc/identifier.hh>
00036 #include <uesqlc/integer.hh>
00037 #include <uesqlc/real.hh>
00038 #include <uesqlc/search_condition.hh>
00039 #include <uesqlc/string.hh>
00040 #include <uesqlc/time.hh>
00041 
00042 
00044 namespace uesqlc
00045 {
00046   
00047   //
00048   //  E X P O R T E D   V A R I A B L E S
00049   //
00050 
00051   //
00052   //  These variables are used in sources generated by UESQLC.
00053   //
00054 
00059   extern long int   SQLCODE;
00060 
00065   extern mpcl::text::TString   SQLMESSAGE;
00066 
00068   extern mpcl::text::TString   SQLSTATE;
00069 
00070   //
00071   //  SQLSTATE class and subclass values.
00072   //    Classes has been represented as a C++ namespace, and subclasses have
00073   //    been represented as a constant pointer to a zero terminated string.
00074   //
00075 
00077   namespace ambiguous_cursor_name
00078   {
00079     extern const char*   pkcNO_SUBCLASS;
00080     enum EValues
00081     {
00082       eNO_SUBCLASS
00083     };
00084   }
00085 
00087   namespace cardinality_violation
00088   {
00089     extern const char*   pkcNO_SUBCLASS;
00090     enum EValues
00091     {
00092       eNO_SUBCLASS = 1000
00093     };
00094   }
00095   
00097   namespace connection_exception
00098   {
00099     extern const char*   pkcNO_SUBCLASS;
00100     extern const char*   pkcCONNECTION_DOES_NOT_EXIST;
00101     extern const char*   pkcCONNECTION_FAILURE;
00102     extern const char*   pkcCONNECTION_NAME_IN_USE;
00103     extern const char*   pkcSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION;
00104     extern const char*   pkcSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION;
00105     extern const char*   pkcTRANSACTION_RESOLUTION_UNKNOWN;
00106     enum EValues
00107     {
00108       eNO_SUBCLASS = 2000                                ,
00109       eCONNECTION_DOES_NOT_EXIST                         ,
00110       eCONNECTION_FAILURE                                ,
00111       eCONNECTION_NAME_IN_USE                            ,
00112       eSQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION       ,
00113       eSQLSERVER_REJECTED_ESTABLISHMENT_OF_SQLCONNECTION ,
00114       eTRANSACTION_RESOLUTION_UNKNOWN
00115     };
00116   }
00117   
00119   namespace data_exception
00120   {
00121     extern const char*   pkcNO_SUBCLASS;
00122     extern const char*   pkcCHARACTER_NOT_IN_REPERTOIRE;
00123     extern const char*   pkcDATETIME_FIELD_OVERFLOW;
00124     extern const char*   pkcDIVISION_BY_ZERO;
00125     extern const char*   pkcERROR_IN_ASSIGNMENT;
00126     extern const char*   pkcINDICATOR_OVERFLOW;
00127     extern const char*   pkcINTERVAL_FIELD_OVERFLOW;
00128     extern const char*   pkcINVALID_CHARACTER_VALUE_FOR_CAST;
00129     extern const char*   pkcINVALID_DATETIME_FORMAT;
00130     extern const char*   pkcINVALID_ESCAPE_CHARACTER;
00131     extern const char*   pkcINVALID_ESCAPE_SEQUENCE;
00132     extern const char*   pkcINVALID_PARAMETER_VALUE;
00133     extern const char*   pkcINVALID_TIME_ZONE_DISPLACEMENT_VALUE;
00134     extern const char*   pkcNULL_VALUE_NO_INDICATOR_PARAMETER;
00135     extern const char*   pkcNUMERIC_VALUE_OUT_OF_RANGE;
00136     extern const char*   pkcSTRING_DATA_LENGTH_MISMATCH;
00137     extern const char*   pkcSTRING_DATA_RIGHT_TRUNCATION;
00138     extern const char*   pkcSUBSTRING_ERROR;
00139     extern const char*   pkcTRIM_ERROR;
00140     extern const char*   pkcUNTERMINATED_C_STRING;
00141     enum EValues
00142     {
00143       eNO_SUBCLASS = 3000                   ,
00144       eCHARACTER_NOT_IN_REPERTOIRE          ,
00145       eDATETIME_FIELD_OVERFLOW              ,
00146       eDIVISION_BY_ZERO                     ,
00147       eERROR_IN_ASSIGNMENT                  ,
00148       eINDICATOR_OVERFLOW                   ,
00149       eINTERVAL_FIELD_OVERFLOW              ,
00150       eINVALID_CHARACTER_VALUE_FOR_CAST     ,
00151       eINVALID_DATETIME_FORMAT              ,
00152       eINVALID_ESCAPE_CHARACTER             ,
00153       eINVALID_ESCAPE_SEQUENCE              ,
00154       eINVALID_PARAMETER_VALUE              ,
00155       eINVALID_TIME_ZONE_DISPLACEMENT_VALUE ,
00156       eNULL_VALUE_NO_INDICATOR_PARAMETER    ,
00157       eNUMERIC_VALUE_OUT_OF_RANGE           ,
00158       eSTRING_DATA_LENGTH_MISMATCH          ,
00159       eSTRING_DATA_RIGHT_TRUNCATION         ,
00160       eSUBSTRING_ERROR                      ,
00161       eTRIM_ERROR                           ,
00162       eUNTERMINATED_C_STRING
00163     };
00164   }
00165   
00167   namespace dependent_privilege_descriptors_still_exist
00168   {
00169     extern const char*   pkcNO_SUBCLASS;
00170     enum EValues
00171     {
00172       eNO_SUBCLASS = 4000
00173     };
00174   }
00175   
00177   namespace dynamic_sql_error
00178   {
00179     extern const char*   pkcNO_SUBCLASS;
00180     extern const char*   pkcCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED;
00181     extern const char*   pkcINVALID_DESCRIPTOR_COUNT;
00182     extern const char*   pkcINVALID_DESCRIPTOR_INDEX;
00183     extern const char*   pkcPREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION;
00184     extern const char*   pkcRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION;
00185     extern const char*   pkcUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC;
00186     extern const char*   pkcUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC;
00187     extern const char*   pkcUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS;
00188     extern const char*   pkcUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS;
00189     enum EValues
00190     {
00191       eNO_SUBCLASS = 5000                                 ,
00192       eCURSOR_SPECIFICATION_CANNOT_BE_EXECUTED            ,
00193       eINVALID_DESCRIPTOR_COUNT                           ,
00194       eINVALID_DESCRIPTOR_INDEX                           ,
00195       ePREPARED_STATEMENT_NOT_A_CURSOR_SPECIFICATION      ,
00196       eRESTRICTED_DATA_TYPE_ATTRIBUTE_VIOLATION           ,
00197       eUSING_CLAUSE_DOES_NOT_MATCH_DYNAMIC_PARAMETER_SPEC ,
00198       eUSING_CLAUSE_DOES_NOT_MATCH_TARGET_SPEC            ,
00199       eUSING_CLAUSE_REQUIRED_FOR_DYNAMIC_PARAMETERS       ,
00200       eUSING_CLAUSE_REQUIRED_FOR_RESULT_FIELDS
00201     };
00202   }
00203   
00205   namespace feature_not_supported
00206   {
00207     extern const char*   pkcNO_SUBCLASS;
00208     extern const char*   pkcMULTIPLE_ENVIRONMENT_TRANSACTIONS;
00209     enum EValues
00210     {
00211       eNO_SUBCLASS = 6000                ,
00212       eMULTIPLE_ENVIRONMENT_TRANSACTIONS
00213     };
00214   }
00215   
00217   namespace integrity_constraint_violation
00218   {
00219     extern const char*   pkcNO_SUBCLASS;
00220     enum EValues
00221     {
00222       eNO_SUBCLASS = 7000
00223     };
00224   }
00225   
00227   namespace invalid_authorization_specification
00228   {
00229     extern const char*   pkcNO_SUBCLASS;
00230     enum EValues
00231     {
00232       eNO_SUBCLASS = 8000
00233     };
00234   }
00235   
00237   namespace invalid_catalog_name
00238   {
00239     extern const char*   pkcNO_SUBCLASS;
00240     enum EValues
00241     {
00242       eNO_SUBCLASS = 9000
00243     };
00244   }
00245   
00247   namespace invalid_character_set_name
00248   {
00249     extern const char*   pkcNO_SUBCLASS;
00250     enum EValues
00251     {
00252       eNO_SUBCLASS = 10000
00253     };
00254   }
00255   
00257   namespace invalid_condition_number
00258   {
00259     extern const char*   pkcNO_SUBCLASS;
00260     enum EValues
00261     {
00262       eNO_SUBCLASS = 11000
00263     };
00264   }
00265   
00267   namespace invalid_connection_name
00268   {
00269     extern const char*   pkcNO_SUBCLASS;
00270     enum EValues
00271     {
00272       eNO_SUBCLASS = 12000
00273     };
00274   }
00275   
00277   namespace invalid_cursor_name
00278   {
00279     extern const char*   pkcNO_SUBCLASS;
00280     enum EValues
00281     {
00282       eNO_SUBCLASS = 13000
00283     };
00284   }
00285   
00287   namespace invalid_cursor_state
00288   {
00289     extern const char*   pkcNO_SUBCLASS;
00290     enum EValues
00291     {
00292       eNO_SUBCLASS = 14000
00293     };
00294   }
00295   
00297   namespace invalid_schema_name
00298   {
00299     extern const char*   pkcNO_SUBCLASS;
00300     enum EValues
00301     {
00302       eNO_SUBCLASS = 15000
00303     };
00304   }
00305   
00307   namespace invalid_sql_descriptor_name
00308   {
00309     extern const char*   pkcNO_SUBCLASS;
00310     enum EValues
00311     {
00312       eNO_SUBCLASS = 16000
00313     };
00314   }
00315   
00317   namespace invalid_sql_statement_name
00318   {
00319     extern const char*   pkcNO_SUBCLASS;
00320     enum EValues
00321     {
00322       eNO_SUBCLASS = 17000
00323     };
00324   }
00325   
00327   namespace invalid_transaction_state
00328   {
00329     extern const char*   pkcNO_SUBCLASS;
00330     enum EValues
00331     {
00332       eNO_SUBCLASS = 18000
00333     };
00334   }
00335   
00337   namespace invalid_transaction_termination
00338   {
00339     extern const char*   pkcNO_SUBCLASS;
00340     enum EValues
00341     {
00342       eNO_SUBCLASS = 19000
00343     };
00344   }
00345   
00347   namespace no_data
00348   {
00349     extern const char*   pkcNO_SUBCLASS;
00350     enum EValues
00351     {
00352       eNO_SUBCLASS = 20000
00353     };
00354   }
00355   
00357   namespace remote_database_access
00358   {
00359     extern const char*   pkcNO_SUBCLASS;
00360     enum EValues
00361     {
00362       eNO_SUBCLASS = 21000
00363     };
00364   }
00365   
00367   namespace successful_completion
00368   {
00369     extern const char*   pkcNO_SUBCLASS;
00370     enum EValues
00371     {
00372       eNO_SUBCLASS = 22000
00373     };
00374   }
00375   
00377   namespace syntax_error_or_access_rule_violation
00378   {
00379     extern const char*   pkcNO_SUBCLASS;
00380     enum EValues
00381     {
00382       eNO_SUBCLASS = 23000
00383     };
00384   }
00385   
00387   namespace syntax_error_or_access_rule_violation_in_direct_statement
00388   {
00389     extern const char*   pkcNO_SUBCLASS;
00390     enum EValues
00391     {
00392       eNO_SUBCLASS = 24000
00393     };
00394   }
00395   
00397   namespace syntax_error_or_access_rule_violation_in_dynamic_statement
00398   {
00399     extern const char*   pkcNO_SUBCLASS;
00400     enum EValues
00401     {
00402       eNO_SUBCLASS = 25000
00403     };
00404   }
00405   
00407   namespace transaction_rollback
00408   {
00409     extern const char*   pkcNO_SUBCLASS;
00410     extern const char*   pkcINTEGRITY_CONSTRAINT_VIOLATION;
00411     extern const char*   pkcSERIALIZATION_FAILURE;
00412     extern const char*   pkcSTATEMENT_COMPLETION_UNKNOWN;
00413     enum EValues
00414     {
00415       eNO_SUBCLASS = 26000            ,
00416       eINTEGRITY_CONSTRAINT_VIOLATION ,
00417       eSERIALIZATION_FAILURE          ,
00418       eSTATEMENT_COMPLETION_UNKNOWN
00419     };
00420   }
00421   
00423   namespace triggered_data_change_violation
00424   {
00425     extern const char*   pkcNO_SUBCLASS;
00426     enum EValues
00427     {
00428       eNO_SUBCLASS = 27000
00429     };
00430   }
00431   
00433   namespace warning
00434   {
00435     extern const char*   pkcNO_SUBCLASS;
00436     extern const char*   pkcCURSOR_OPERATION_CONFLICT;
00437     extern const char*   pkcDISCONNECT_ERROR;
00438     extern const char*   pkcIMPLICIT_ZERO_BIT_PADDING;
00439     extern const char*   pkcINSUFFICIENT_ITEM_DESCRIPTOR_AREAS;
00440     extern const char*   pkcNULL_VALUE_ELIMINATED_IN_SET_FUNCTION;
00441     extern const char*   pkcPRIVILEGE_NOT_GRANTED;
00442     extern const char*   pkcPRIVILEGE_NOT_REVOKED;
00443     extern const char*   pkcQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA;
00444     extern const char*   pkcSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA;
00445     extern const char*   pkcSTRING_DATA_RIGHT_TRUNCATION;
00446     enum EValues
00447     {
00448       eNO_SUBCLASS = 28000                              ,
00449       eCURSOR_OPERATION_CONFLICT                        ,
00450       eDISCONNECT_ERROR                                 ,
00451       eIMPLICIT_ZERO_BIT_PADDING                        ,
00452       eINSUFFICIENT_ITEM_DESCRIPTOR_AREAS               ,
00453       eNULL_VALUE_ELIMINATED_IN_SET_FUNCTION            ,
00454       ePRIVILEGE_NOT_GRANTED                            ,
00455       ePRIVILEGE_NOT_REVOKED                            ,
00456       eQUERY_EXPRESSION_TOO_LONG_FOR_INFORMATION_SCHEMA ,
00457       eSEARCH_CONDITION_TOO_LONG_FOR_INFORMATION_SCHEMA ,
00458       eSTRING_DATA_RIGHT_TRUNCATION
00459     };
00460   }
00461   
00463   namespace with_check_option_violation
00464   {
00465     extern const char*   pkcNO_SUBCLASS;
00466     enum EValues
00467     {
00468       eNO_SUBCLASS = 29000
00469     };
00470   }
00471 
00473   class TSqlstateDescriptor
00474   {
00475 
00476     private:
00477 
00482       static mpcl::util::collection::TMap<mpcl::text::TString, int>   _tValueToIntMap;
00483 
00484 
00485     protected:
00486       
00487       //
00488       //  L O C A L   F U N C T I O N S
00489       //
00490 
00496       static void _addCondition (const char* pkcSQLSTATE, int iVALUE);
00497 
00499       static void _initialize (void);
00500       
00501       
00502     public:
00503 
00504       //
00505       //  C O N S T R U C T O R S
00506       //
00507 
00509       TSqlstateDescriptor (void)
00510       {
00511         _initialize();
00512       }
00513 
00514 
00515     public:
00516 
00517       //
00518       //  S E L E C T O R S
00519       //
00520 
00525       bool queryIsEmpty (void) const
00526       {
00527         return ( getUniqueValue() == no_data::eNO_SUBCLASS );
00528       }
00529 
00534       bool queryHasSingleRow (void) const
00535       {
00536         //
00537         //  Check if query has generated only *one* row.
00538         //
00539         return ( ( getUniqueValue() != cardinality_violation::eNO_SUBCLASS ) &&
00540                  ( getUniqueValue() != no_data::eNO_SUBCLASS )                );
00541       }
00542 
00547       int getUniqueValue (void) const
00548       {
00549         using mpcl::text::TString;
00550         using mpcl::util::collection::TMap;
00551 
00552         TMap<TString, int>::const_iterator   I;
00553         register int                         iUniqueValue = -1;
00554 
00555         I = _tValueToIntMap.find (SQLSTATE);
00556         if ( I != _tValueToIntMap.end() )
00557         {
00558           iUniqueValue = I->second;
00559         }        
00560         return iUniqueValue;
00561       }
00562 
00567       int getUniqueValue (const char* pkcSQLSTATE) const
00568       {
00569         return _tValueToIntMap [pkcSQLSTATE];
00570       }
00571 
00576       const char* getClassValue (void) const
00577       {
00578         return getClassValue (SQLSTATE.c_str());
00579       }
00580       
00585       const char* getClassValue (const char* pkcSQLSTATE) const;
00586       
00592       mpcl::text::TString getDescription (const char* pkcSQLSTATE) const;
00593       
00598       const char* getSubclassValue (void) const
00599       {
00600         return getSubclassValue (SQLSTATE.c_str());
00601       }
00602       
00607       const char* getSubclassValue (const char* pkcSQLSTATE) const;
00608 
00609   };  // class TSqlstateDescriptor
00610 
00611 
00613   class TNotFoundException                 :
00614     public virtual mpcl::TException        ,
00615     public         mpcl::TWarningException ,
00616     private        TSqlstateDescriptor
00617   {
00618 
00619     public:
00620 
00627       TNotFoundException ( const char* pkcFILE_NAME  ,
00628                            const int   kiLINE_NUMBER );
00629 
00630 
00631     public:
00632 
00633       //
00634       //  S E L E C T O R S
00635       //
00636 
00637       const std::string what (void) const;
00638 
00639   };  // class TNotFoundException
00640 
00641 
00643   class TSqlerrorException               :
00644     public virtual mpcl::TException      ,
00645     public         mpcl::TErrorException ,
00646     private        TSqlstateDescriptor
00647   {
00648 
00649     public:
00650 
00657       TSqlerrorException ( const char* pkcFILE_NAME  ,
00658                            const int   kiLINE_NUMBER );
00659 
00660 
00661     public:
00662 
00663       //
00664       //  S E L E C T O R S
00665       //
00666 
00667       const std::string what (void) const;
00668 
00669   };  // class TSqlerrorException
00670 
00671 
00672   //
00673   //  E X P O R T E D   F U N C T I O N S
00674   //
00675 
00676   //
00677   //  Simple n-adic functions for embedded function calls.
00678   //
00679 
00686   TString ComposeSchemaLocation ( const std::string& rkyHOST_NAME   ,
00687                                   const std::string& rkySCHEMA_NAME );
00688 
00695   TString ComposeUserLogin ( const std::string& rkyUSER_NAME     ,
00696                              const std::string& rkyUSER_PASSWORD );
00697 
00704   TString ToString (bool gVALUE);
00705   
00712   TString ToString (long double ldNUMBER);
00713   
00720   TString ToString (long int liNUMBER);
00721   
00728   TString ToString (long unsigned int luiNUMBER);
00729   
00730 }  // namespace uesqlc
00731 
00732 
00733 #endif  // not _UESQL_DEFS__

Generated on Mon Oct 13 02:40:10 2003 for UESQLC by doxygen1.2.18