Appendix B. The GNU.DB Packages

Table of Contents
GNU.DB.ESQL_Support
ODBC related packages

GNU.DB.ESQL_Support

This package contains procedure and functions common to all data base interfaces used by the gesql. Most of the functions located in this package are dedicated to the mapping between ISO/92 and Ada 95 data types.

String related type conversion

   with SQL_STANDARD;            use SQL_STANDARD;
   with GNU.DB.ESQL_SUPPORT;     use GNU.DB.ESQL_SUPPORT;

   function To_String(
      Item      : in SQL_STANDARD.CHAR ) return String;
 
   procedure To_String(
      Item      : in SQL_STANDARD.CHAR;
      Target    : out String );
 
   procedure Move(
      S : in String ;
      C : out Sql_Standard.Char );                

These function is used to convert between ISO/92 Strings and the Ada String type.

SQL Communication Area

This package contains the definition of the SQL communication area, which is updated after each issued sql query.

   type SQLCA_Type is record
         Message   : aliased String(1..255 );
         State     : aliased SQLSTATE_TYPE;
         SqlCode   : aliased SQLCODE_TYPE;
      end record;                            
   

The field Message contains a string which is generated by the underlying dbcs in case of errors as informational string. State and SQLCODE contain the result of the last query.

The state variable is a string of 4 characters. The first 2 characters denote the class of the state. The constants SUCCESS_CLASS, WARNING_CLASS and NOT-FOUND_CLASS may be used to distinguish the different error classes as shown below:

   
      if SQLCA.State(1..2) = NOTFOUND_CLASS then
       .....
      end if;
   

Exceptions

This package defines some implementation defined exceptions.

   Out_Of_Resources     : exception ;
   No_Reopenable_Cursor : exception ;        
   

The Out_Of_Resources exception is raised by the ESQL_Support module in case where no more internal resources are available. Normally there is no recovery possible and the application should terminate cleanly.

The exception No_Reopenable_Cursor is raised, if a cursor is opened which is not declared as reopen able or local.