home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 37 / IOPROG_37.ISO / SOFT / orient / Linux / demo / selectAllInvoice.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-15  |  1.6 KB  |  75 lines

  1. #ifdef COMP_BCB
  2. // BORLAND C++ BUILDER INCLUDES
  3. #include <condefs.h>
  4. #else
  5. #define USELIB( arg )
  6. #endif
  7.  
  8.  
  9. //---------------------------------------------------------------------------
  10. // CUSTOM DATABASE HEADER
  11. #include "business.h"
  12. //---------------------------------------------------------------------------
  13. #include <stdio.h>
  14. //---------------------------------------------------------------------------
  15. // BORLAND C++ BUILDER DIRECTIVES
  16. USELIB("..\..\..\lib\win32\bcb\ojust.lib");
  17.  
  18.  
  19. //---------------------------------------------------------------------------
  20. int main(int argc, char* argv[])
  21. {
  22.   // START TRY/CATCH BLOCK FOR EXCEPTIONS CATCHING
  23.   try
  24.   {
  25.     d_Database    db;
  26.     d_Transaction tx;
  27.  
  28.     // OPEN DATABASE
  29.     db.open( "database/business" );
  30.  
  31.     // START TRANSACTION
  32.     tx.begin();
  33.  
  34.     d_Ref<Invoice>            objInvoice;
  35.     d_Iterator< d_Ref<Invoice> >    itInvoice;
  36.     d_Extent<Invoice>            invoices( &db );
  37.     char                query[100];
  38.     d_Iterator< d_Ref<Product> >    itProduct;
  39.     d_Ref<Product>            objProduct;
  40.  
  41.     /* FORMAT QUERY COMMAND */
  42.     sprintf( query, "" );
  43.     itInvoice = invoices.select( query );
  44.  
  45.     while( itInvoice.next( objInvoice ) )
  46.     {
  47.       objInvoice->ownCustomer.ptr();
  48.  
  49.       itProduct = objInvoice->products.create_iterator();
  50.       while( itProduct.next( objProduct ) )
  51.       {
  52.         objProduct.ptr();
  53.       }
  54.     }
  55.  
  56.     // COMMIT TRANSACTION
  57.     tx.commit();
  58.   }
  59.   catch( d_Error &e )
  60.   {
  61.     // DATABASE ERROR
  62.       cout << "d_Error " << e.what() << endl;
  63.   }
  64.   catch( ... )
  65.   {
  66.     // APPLICATION ERROR
  67.       cout << "ERRORE" << endl;
  68.   }
  69.  
  70.   return 0;
  71. }
  72.  
  73.  
  74.  
  75.