home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / CONTRIB / MBASE / MBASE51.TAR / mbase51 / examples / example4.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-04  |  1.4 KB  |  85 lines

  1. #include <mbase.h>
  2. #include "example4.h"
  3.  
  4. /*
  5.  * PROTOTYPES -----------------------------------------------------------------
  6.  *
  7.  */
  8.  
  9.    void main XARGS( (void) );
  10.  
  11.  
  12. /*
  13.  * CODE -----------------------------------------------------------------------
  14.  *
  15.  */
  16.  
  17. void
  18. main ()
  19. {
  20.    relation *rel;
  21.    example4  rec;
  22.  
  23.  
  24. /*
  25.  * First step in adding new records is, of course, opening the relation...
  26.  *
  27.  */
  28.  
  29.    if ((rel = mb_inc ("example4", "")) == RNULL)
  30.       {
  31.       fprintf (stderr, "mb_inc() failed: %s\n", mb_error);
  32.       mb_exit (1);
  33.       }
  34.  
  35.  
  36. /*
  37.  * Got it.  Now add a couple of records...
  38.  *
  39.  */
  40.  
  41.    strcpy (rec.composer, "Bach");
  42.    strcpy (rec.piece,    "Fugue in G-minor");
  43.    rec.price = 15.79;
  44.  
  45.    if (mb_add (rel, &rec) != MB_OKAY)
  46.       {
  47.       fprintf (stderr, "mb_add() failed: %s\n", mb_error);
  48.       mb_exit (1);
  49.       }
  50.  
  51.  
  52.    strcpy (rec.composer, "Beethoven");
  53.    strcpy (rec.piece,    "9th symphony");
  54.    rec.price = 21.50;
  55.  
  56.    if (mb_add (rel, &rec) != MB_OKAY)
  57.       {
  58.       fprintf (stderr, "mb_add() failed: %s\n", mb_error);
  59.       mb_exit (1);
  60.       }
  61.  
  62.  
  63.    strcpy (rec.composer, "Fat Boys");
  64.    strcpy (rec.piece,    "On and on");
  65.    rec.price = 11.99;
  66.  
  67.    if (mb_add (rel, &rec) != MB_OKAY)
  68.       {
  69.       fprintf (stderr, "mb_add() failed: %s\n", mb_error);
  70.       mb_exit (1);
  71.       }
  72.  
  73.  
  74. /*
  75.  * Now close the relation, and exit
  76.  *
  77.  */
  78.  
  79.    printf ("records added successfully\n");
  80.  
  81.    mb_rmv (rel);
  82.    mb_exit (0);
  83. }
  84.  
  85.