home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / cdb114.zip / CDB.DOC next >
Text File  |  1991-03-27  |  44KB  |  1,587 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.                       C DataBase Management System (CDB)
  23.  
  24.  
  25.                                  Version 1.14
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.                         Copyright (C) 1989, 1990, 1991
  54.                                       by
  55.                                     Daytris
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                   Introduction
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.     CDB is a complete database development kit designed for C programmers.
  72.  
  73.     CDB is based on both NETWORK and RELATIONAL database models and uses
  74.     a B-TREE/ISAM methodology for key file management.  The kit also uses
  75.     the advanced concept of a Data Definition Language (DDL).  Using the
  76.     DDL, a developer can design and re-design their database with minimal
  77.     effort and absolutely no code changes.
  78.  
  79.     Libraries are available for both Microsoft and Turbo C under MS-DOS.
  80.     The libraries included in this trial version are compiled for the small
  81.     memory model.  Other memory models are available with registration.
  82.     Source code is also available.
  83.  
  84.     There is a version of CDB for UNIX and an MS-Windows release will be
  85.     available early in the second quarter of 1991.
  86.  
  87.     CDB is written entirely in C for portability.
  88.  
  89.     If you have any questions about CDB, please call us at (201) 332-5228
  90.     or send a message to any of the BBS's listed below:
  91.  
  92.     Developers: Daytris
  93.                 81 Bright Street, Suite 1E
  94.                 Jersey City, NJ 07302
  95.                 (201) 332-5228
  96.  
  97.                 CompuServe ID:  72500,1426
  98.                 BIX:            daytris
  99.                 GEnie:          t.fearn
  100.  
  101.  
  102.  
  103.                           Database Development Files
  104.  
  105.  
  106.  
  107.         These files are contained in the ZIP file CDB114.ZIP:
  108.  
  109.         CDB.DOC         This file
  110.         UPDATES.DOC     A history of CDB modifications
  111.         MSCCDBS.LIB     Microsoft C database development library (small
  112.                         model)
  113.         TCCDBS.LIB      Turbo C database development library (small model)
  114.         DDLP.EXE        Data Definition Language Parser
  115.         DBDLIST.EXE     Database Definition (DBD) file display utility
  116.         DBMGR.H         Database development header file
  117.         TEST.DDL        Example DDL (Data Definition Language) file
  118.         TEST.C          Example CDB development file
  119.       * MSCTEST.MAK     Microsoft C test.c make file
  120.       * TCTEST.MAK      Turbo C test.c make file
  121.  
  122.  
  123.         These files are contained in the ZIP file CDBSRC.ZIP:
  124.         (Received upon registration)
  125.  
  126.         DBMGR.C         CDB source files
  127.         DBFIND.C
  128.         DBGET.C
  129.         DBADD.C
  130.         DBUPD.C
  131.         DBDEL.C
  132.         DBCURR.C
  133.         DBPAGE.C
  134.         DBSLOT.C
  135.         DBFILE.C
  136.         DBFUNCS.C
  137.         STDINC.H        CDB header files
  138.         DBXTRN.H
  139.       * MSCLIB.MAK      Microsoft C CDB library make file
  140.       * TCLIB.MAK       Turbo C CDB library make file
  141.  
  142.         MAIN.C          DDLP source files
  143.         PARSE.C
  144.         DDLP.C
  145.         ERROR.C
  146.         DDLP.H          DDLP header file
  147.       * DDLP.MAK        DDLP make file
  148.  
  149.         DBDLIST.C       DBDLIST source file
  150.       * DBDLIST.MAK     DBDLIST make file
  151.  
  152.  
  153.     * All make files are Unix Make compatible.
  154.  
  155.  
  156.  
  157.                         Data Definition Language (DDL)
  158.  
  159.  
  160.     The Data Definition Language is used to define your database.  DDLP
  161.     (Data Definition Language Parser) is used to create a .DBD (Database
  162.     Definition) file from the .DDL (Data Definition Language) file.  The
  163.     .DBD file is read into memory when the database is opened and is used
  164.     as a map into this particular database.  DDLP will also output a C
  165.     header file defining your database records in a standard C format.
  166.  
  167.     This concept allows you to change your database model at will during
  168.     the development cycle of your project without changing one line of
  169.     development code.
  170.  
  171.     A sample DDL (test.ddl) is included in this kit.  Notice that the DDL
  172.     is very similar to a C header file.  The only differences from a
  173.     standard C header file are the keywords: PREFIX, CONNECT, and KEY.
  174.  
  175.  
  176.     PREFIX
  177.  
  178.     Before we can discuss this prefix, you must first know how the database
  179.     files are created.  For each record defined in the DDL, a separate
  180.     data and a separate key file will be created when you add the first
  181.     record of this type.  The key file will only be created if you have
  182.     a key field in the record.  The data file for the first record in the
  183.     DBD is named XXXX0001.DAT where XXXX is the predefined prefix.  The
  184.     key file is named XXXX0001.KEY.
  185.  
  186.     The prefix can be up to 4 characters.  This prefix is not required.
  187.     For example, if you choose a prefix of "ABC" as shown in test.ddl, when
  188.     the first record of the first file is added, two files will be created.
  189.     They will be ABC0001.KEY and ABC0001.DAT.
  190.  
  191.     Note: Keep in mind that the first record in the DDL may not correspond
  192.           to the file name XXXX0001.XXX.  This is because DDLP rearranges
  193.           the records in alphabetic order when it creates the DBD.  So the
  194.           XXXX0001.XXX file will correspond to the alphabetically lowest
  195.           record value in the DDL.
  196.  
  197.  
  198.     CONNECT
  199.  
  200.     This keyword allows you to make connections between records without
  201.     physically storing keys in each record to connect them.
  202.  
  203.     For example, if you would like to connect an "Invoice" to a "Customer"
  204.     using the RELATIONAL model, you must store a unique key in both
  205.     records and then retrieve the records using the unique key.  Using
  206.     the NETWORK model, once you add the "Customer" and the "Invoice", you
  207.     can make a set connection between the two records using the "DbSetAdd"
  208.     macro.  DbSetAdd( "Customer", "Invoice");  "Customer" becomes the
  209.     owner of the "Invoice".  "Invoice" is a member of that particular
  210.     "Customer".  The connection is only possible if you have defined in
  211.     the "Customer" record a connection to the "Invoice" record.  This is
  212.     a one-to-many relationship.
  213.  
  214.  
  215.  
  216.     To create a many-to-many relationship using the same example, a
  217.     "connect Customer;" placed in the "Invoice" record would enable you to
  218.     make the "Customer" a member record of the "Invoice".  Using the macro
  219.     DbSetAdd( "Invoice", "Customer"); would make the set connection.
  220.     Although you may rarely see the need for a many-to-many relationship,
  221.     the power to do so is available.
  222.  
  223.     Beginning with release 1.13 of CDB, set connections can be stored by
  224.     a key value, if so desired.  This is accomplished by expanding the
  225.     CONNECT phrase to 'CONNECT record_name KEY key_field_name'.  The
  226.     key_field_name can be any field name in the member record.  It does
  227.     not have to be a key field in the member record.  Example:
  228.  
  229.         /* test.ddl */
  230.  
  231.         struct Customer
  232.             {
  233.             connect             Address key street;
  234.             connect             Invoice;
  235.             key long            acctNbr;
  236.             key char            company[31];
  237.             double              balance;
  238.             };
  239.  
  240.         struct Address
  241.             {
  242.             char                street[31];
  243.             char                city[21];
  244.             char                state[3];
  245.             key char            zip[10];
  246.             key char            telephone[11];
  247.             };
  248.  
  249.     When set connections are made (e.g. DbSetAdd("Customer","Address")),
  250.     the Address members will be stored by 'street'.  If no key were
  251.     specified for the connection, the members would be stored in the
  252.     order in which they are added.
  253.  
  254.     Note: Keep in mind that to use CDB, you are not required to use
  255.           the CONNECT keyword in your database model (DDL).  Depending
  256.           on your specific requirements, you may find it advantageous
  257.           to use only the RELATIONAL features of CDB.
  258.  
  259.  
  260.     KEY
  261.  
  262.     This keyword simply defines a key field for a record.  You can have
  263.     up to 8 keys per record and the maximum size of a key field is 256
  264.     bytes.  If you have registered and have the source code, these
  265.     limitations can be overcome very easily by modifying #define values.
  266.     If a record is defined with no keys, that record cannot be accessed
  267.     unless there is a set connection to that particular record.
  268.  
  269.  
  270.  
  271.                                   Utilities
  272.  
  273.  
  274.  
  275.     DDLP.EXE
  276.  
  277.     DDLP is the DDL parser (compiler) that creates a DataBase Definition
  278.     file (.DBD) from the DDL.  This .DBD file is used as a map into the
  279.     database when this database is opened.  DDLP also creates a header
  280.     file from the DDL for use in your C program.
  281.  
  282.     Usage: DDLP filename(.ddl)
  283.  
  284.  
  285.  
  286.  
  287.     DBDLIST.EXE
  288.  
  289.     DBDLIST is a DBD display utility.  Using this utility you can display
  290.     the internal contents of a .DBD file.
  291.  
  292.     Usage: DBDLIST filename.dbd
  293.  
  294.  
  295.  
  296.                          Modifying the Database Design
  297.  
  298.  
  299.  
  300.     It is very simple to modify the general database design by changing
  301.     some of the defined values in DBMGR.H.
  302.  
  303.  
  304.     #define NBRHANDLES 12
  305.  
  306.     This value is the number of file handles allowed to be open by the
  307.     database at one time.  If you have a database with a large number of
  308.     records, it is a good idea to leave this value alone or increase it
  309.     slightly.  Remember that the maximum number of file handles available
  310.     for a process under DOS is 20 and the system uses 5.  If your database
  311.     has only a few records, it may be a good idea to lower this value.
  312.  
  313.     For example, suppose your database has only 3 records.  Each has at
  314.     least one key field.  Since the maximum number of files for this
  315.     database is 6, you should reduce the NBRHANDLES to 6.
  316.  
  317.     The file handles are opened and closed using an LRU (least recently
  318.     used) algorithm for maximum file handle management.
  319.  
  320.  
  321.     #define MAXKEY 8
  322.  
  323.     This value is the maximum number of keys that a single record can have.
  324.     You can adjust this value according to your usage.  It is recommended
  325.     that this value be a power of 2.
  326.  
  327.  
  328.     #define KEYPAGESIZE 512
  329.  
  330.     This value is the size of a page for the .key data files.  The keys
  331.     in the database are stored on pages in a sorted order.  The pages are
  332.     linked together through a link list.  If your database key fields are
  333.     very large, you may wish to increase this value to store more keys on
  334.     a page.  Note: The larger the key page size, the longer the access
  335.     time for read and writing.  It is recommended that this value be a
  336.     power of 2.
  337.  
  338.  
  339.     #define NBRPAGES 16
  340.  
  341.     This value is the number of key pages that are buffered in RAM.  These
  342.     buffers are accessed using an LRU (least recently used) algorithm for
  343.     maximum page management.
  344.  
  345.  
  346.     #define DATAPAGESIZE 2048
  347.  
  348.     This value is the size of a page for the .dat data files.  Each record
  349.     is stored in slots on pages in the data files.  Each slot has some
  350.     reserved information at beginning of each slot.  It is recommended that
  351.     this value be a power of 2.
  352.  
  353.  
  354.  
  355.     #define DATASLOTSIZE 1024
  356.  
  357.     This value is the maximum size of a data slot.  Each data file is made
  358.     up of pages which consist of a group of slots.  You will need to
  359.     increase this value if any of your record sizes, when plugged into the
  360.     formula below, exceed 1024.
  361.  
  362.     Formula: (C structure byte length) + 6 +
  363.              (number of owners of this record * 8) +
  364.              (number of members of this record * 12) > 1024
  365.  
  366.     If you have very large C structures you should check them.  It is
  367.     recommended that DATASLOTSIZE be a power of 2.
  368.  
  369.  
  370.  
  371.                              Database Macro Index
  372.  
  373.  
  374.  
  375.  
  376.  
  377.     General Database Macros
  378.  
  379.     void DbClose( void);
  380.     void DbFlush( void);
  381.     int  DbOpen( char *database);
  382.  
  383.  
  384.     Record Macros
  385.  
  386.     int  DbRecordAdd( char *record, char *source);
  387.     int  DbRecordDelete( char *record);
  388.     int  DbRecordFindByKey( char *record, char *field, char *key);
  389.     int  DbRecordFindFirst( char *record, char *field);
  390.     int  DbRecordFindLast( char *record, char *field);
  391.     int  DbRecordFindNext( char *record, char *field);
  392.     int  DbRecordFindPrev( char *record, char *field);
  393.     int  DbRecordGetCurrency( char *record, char *currency);
  394.     int  DbRecordGetByKey( char *record, char *field, char *target, char *key);
  395.     int  DbRecordGetCurrent( char *record, char *field, char *target);
  396.     int  DbRecordGetFirst( char *record, char *field, char *target);
  397.     int  DbRecordGetLast( char *record, char *field, char *target);
  398.     int  DbRecordGetNext( char *record, char *field, char *target);
  399.     int  DbRecordGetPrev( char *record, char *field, char *target);
  400.     int  DbRecordUpdate( char *record, char *source);
  401.     int  DbRecordUpdCurrency( char *record, char *currency);
  402.  
  403.  
  404.     Set Macros
  405.  
  406.     int  DbSetAdd( char *owner, char *member);
  407.     int  DbSetDelete( char *owner, char *member);
  408.     int  DbSetFindFirst( char *owner, char *member);
  409.     int  DbSetFindLast( char *owner, char *member);
  410.     int  DbSetFindNext( char *owner, char *member);
  411.     int  DbSetFindPrev( char *owner, char *member);
  412.     int  DbSetGetFirst( char *owner, char *member, char *target);
  413.     int  DbSetGetLast( char *owner, char *member, char *target);
  414.     int  DbSetGetNext( char *owner, char *member, char *target);
  415.     int  DbSetGetOwner( char *owner, char *member, char *target);
  416.     int  DbSetGetPrev( char *owner, char *member, char *target);
  417.  
  418.  
  419.     All database macros call the function "dbc" to provide one central
  420.     entry and exit point in the database.
  421.  
  422.  
  423.  
  424.  
  425.     DbClose
  426.     -------------------------------------------------------------------------
  427.  
  428.  
  429.  
  430.     void DbClose( void);
  431.  
  432.  
  433.     Description
  434.  
  435.         This call closes the database that is currently open.
  436.  
  437.  
  438.     Example
  439.  
  440.         #include "dbmgr.h"
  441.  
  442.         main()
  443.             {
  444.             strcpy( dbpath, "\\PROJECT\\DATA");
  445.  
  446.             if( DbOpen( "test.dbd"))
  447.                 {
  448.                 ...error handling
  449.                 }
  450.  
  451.                 .
  452.                 .
  453.                 .
  454.  
  455.             Dbclose();
  456.             }
  457.  
  458.  
  459.  
  460.  
  461.     DbFlush
  462.     -------------------------------------------------------------------------
  463.  
  464.  
  465.  
  466.     void DbFlush( void);
  467.  
  468.  
  469.     Description
  470.  
  471.         This function forces all data written to the database to disk.
  472.  
  473.  
  474.     Example
  475.  
  476.         #include "dbmgr.h"
  477.  
  478.         Function()
  479.             {
  480.             DbRecordUpdate( "customer", &customer);
  481.  
  482.             DbFlush();
  483.             }
  484.  
  485.  
  486.  
  487.  
  488.     DbOpen
  489.     -------------------------------------------------------------------------
  490.  
  491.  
  492.  
  493.     int DbOpen( database);
  494.         char *database;                         Database name
  495.  
  496.  
  497.     Description
  498.  
  499.         This call opens a database.  The database must be a DBD (DataBase
  500.         dictionary) created using DDLP.  Only one database can be opened at
  501.         a time.  The global "dbpath" buffer can be used to define the
  502.         database path.  If "dbpath" is not set, the default path is the
  503.         current directory.
  504.         
  505.  
  506.     Example
  507.  
  508.         #include "dbmgr.h"
  509.  
  510.         main()
  511.             {
  512.             strcpy( dbpath, "\\PROJECT\\DATA");
  513.  
  514.             if( DbOpen( "test.dbd"))
  515.                 {
  516.                 ...error handling
  517.                 }
  518.             }
  519.  
  520.  
  521.  
  522.  
  523.     DbRecordAdd
  524.     -------------------------------------------------------------------------
  525.  
  526.  
  527.  
  528.     int DbRecordAdd( record, source);
  529.         char *record;                           Record name
  530.         char *source;                           Source pointer
  531.         
  532.  
  533.     Description
  534.         Add a record to the database.
  535.  
  536.  
  537.     Example
  538.  
  539.         #include "dbmgr.h"
  540.  
  541.         Function()
  542.             {
  543.             struct CustomerTable customer;
  544.  
  545.                 .
  546.                 .
  547.                 .
  548.             fill record
  549.                 .
  550.                 .
  551.                 .
  552.  
  553.             if( DbRecordAdd( "customer", (char *)&customer))
  554.                 printf( "Error: adding customer record\n");
  555.             }
  556.  
  557.  
  558.  
  559.  
  560.     DbRecordDelete
  561.     -------------------------------------------------------------------------
  562.  
  563.  
  564.  
  565.     int DbRecordDelete( record);
  566.         char *record;                           Record name
  567.         
  568.  
  569.     Description
  570.         Delete a record in the database.  The record you wish to delete must
  571.         be current.
  572.  
  573.  
  574.     Example
  575.  
  576.         #include "dbmgr.h"
  577.  
  578.         Function()
  579.             {
  580.             long accountNbr = 1000L;
  581.             struct CustomerTable customer;
  582.  
  583.  
  584.             if( DbRecordFindByKey( "customer", "acctnbr",
  585.                 (char *)&accountNbr))
  586.                 {
  587.                 printf( "Error: finding customer record\n");
  588.                 }
  589.  
  590.             if( DbRecordDelete( "customer"))
  591.                 printf( "Error: deleting customer record);
  592.             }
  593.  
  594.  
  595.  
  596.  
  597.     DbRecordFindByKey
  598.     -------------------------------------------------------------------------
  599.  
  600.  
  601.  
  602.     int DbRecordFindByKey( record, field, key);
  603.         char *record;                           Record name
  604.         char *field;                            Key field name
  605.         char *key;                              Key value used in search
  606.         
  607.  
  608.     Description
  609.         Find a specific record using a key field and a key value.  If the
  610.         exact match cannot be found the function will return E_NEXTGUESS
  611.         specifying that the match returned is the next best guess.
  612.  
  613.  
  614.     Example
  615.  
  616.         #include "dbmgr.h"
  617.  
  618.         Function()
  619.             {
  620.             unsigned long accountNbr = 1000L;
  621.  
  622.             if( DbRecordFindByKey( "customer", "acctnbr",
  623.                 (char *)&accountNbr))
  624.                 {
  625.                 printf( "Error: customer not found\n");
  626.                 }
  627.  
  628.             if( DbRecordFindByKey( "customer", "company",
  629.                 "Charter Insurance Inc."))
  630.                 {
  631.                 printf( "Error: customer not found\n");
  632.                 }
  633.             }
  634.  
  635.  
  636.  
  637.  
  638.     DbRecordFindFirst
  639.     -------------------------------------------------------------------------
  640.  
  641.  
  642.  
  643.     int DbRecordFindFirst( record, field);
  644.         char *record;                           Record name
  645.         char *field;                            Key field name
  646.         
  647.  
  648.     Description
  649.         Find the first record of a certain record type.  The record must be
  650.         retreived using a key field.
  651.  
  652.  
  653.     Example
  654.  
  655.         #include "dbmgr.h"
  656.  
  657.         Function()
  658.             {
  659.             if( DbRecordFindFirst( "customer", "zipcode"))
  660.                 printf( "Error: customer not found\n");
  661.             }
  662.  
  663.  
  664.  
  665.  
  666.     DbRecordFindLast
  667.     -------------------------------------------------------------------------
  668.  
  669.  
  670.  
  671.     int DbRecordFindLast( record, field);
  672.         char *record;                           Record name
  673.         char *field;                            Key field name
  674.         
  675.  
  676.     Description
  677.         Find the last record of a certain record type.  The record must be
  678.         retreived using a key field.
  679.  
  680.  
  681.     Example
  682.  
  683.         #include "dbmgr.h"
  684.  
  685.         Function()
  686.             {
  687.             if( DbRecordFindLast( "customer", "zipcode"))
  688.                 printf( "Error: customer not found\n");
  689.             }
  690.  
  691.  
  692.  
  693.  
  694.     DbRecordFindNext
  695.     -------------------------------------------------------------------------
  696.  
  697.  
  698.  
  699.     int DbRecordFindNext( record, field);
  700.         char *record;                           Record name
  701.         char *field;                            Key field name
  702.         
  703.  
  704.     Description
  705.         Find the next record of a certain record type.  The record must be
  706.         retreived using a key field.
  707.  
  708.  
  709.     Example
  710.  
  711.         #include "dbmgr.h"
  712.  
  713.         Function()
  714.             {
  715.             if( DbRecordFindNext( "customer", "zipcode"))
  716.                 printf( "Error: customer not found\n");
  717.             }
  718.  
  719.  
  720.  
  721.  
  722.     DbRecordFindPrev
  723.     -------------------------------------------------------------------------
  724.  
  725.  
  726.  
  727.     int DbRecordFindPrev( record, field);
  728.         char *record;                           Record name
  729.         char *field;                            Key field name
  730.         
  731.  
  732.     Description
  733.         Find the previous record of a certain record type.  The record must
  734.         be retreived using a key field.
  735.  
  736.  
  737.     Example
  738.  
  739.         #include "dbmgr.h"
  740.  
  741.         Function()
  742.             {
  743.             if( DbRecordFindLast( "customer", "zipcode"))
  744.                 printf( "Error: customer not found\n");
  745.             }
  746.  
  747.  
  748.  
  749.  
  750.     DbRecordGetCurrency
  751.     -------------------------------------------------------------------------
  752.  
  753.  
  754.  
  755.     int DbRecordGetCurrency( record, currency);
  756.         char *record;                           Record name
  757.         char *currency;                         Ptr to currency record
  758.  
  759.  
  760.     Description
  761.  
  762.         This function allows you to save the current position (currency) of
  763.         a specific record type.
  764.  
  765.  
  766.     Example
  767.  
  768.         #include "dbmgr.h"
  769.  
  770.         Function()
  771.             {
  772.             struct currency_index currency;
  773.  
  774.             DbRecordGetCurrency( (char *)¤cy, "customer");
  775.  
  776.                 .
  777.                 .
  778.                 .
  779.             processing
  780.                 .
  781.                 .
  782.                 .
  783.  
  784.             DbRecordUpdCurrency( (char *)¤cy, "customer");
  785.             }
  786.  
  787.  
  788.  
  789.  
  790.     DbRecordGetByKey
  791.     -------------------------------------------------------------------------
  792.  
  793.  
  794.  
  795.     int DbRecordGetByKey( record, field, target, key);
  796.         char *record;                           Record name
  797.         char *field;                            Key field name
  798.         char *target;                           Destination pointer
  799.         char *key;                              Key value used in search
  800.         
  801.  
  802.     Description
  803.         Get a specific record using a key field and a key value.  If the
  804.         exact match cannot be found the function will return E_NEXTGUESS
  805.         specifying that the match returned is the next best guess.
  806.  
  807.  
  808.     Example
  809.  
  810.         #include "dbmgr.h"
  811.  
  812.         Function()
  813.             {
  814.             unsigned long accountNbr = 1000L;
  815.             struct CustomerTable customer;
  816.  
  817.             if( DbRecordGetByKey( "customer", "acctnbr", (char *)&customer,
  818.                 (char *)&accountNbr))
  819.                 {
  820.                 printf( "Error: customer not found\n");
  821.                 }
  822.  
  823.             if( DbRecordGetByKey( "customer", "company", (char *)&customer,
  824.                 "Charter Insurance Inc."))
  825.                 {
  826.                 printf( "Error: customer not found\n");
  827.                 }
  828.             }
  829.  
  830.  
  831.  
  832.  
  833.     DbRecordGetCurrent
  834.     -------------------------------------------------------------------------
  835.  
  836.  
  837.  
  838.     int DbRecordGetCurrent( record, field, target);
  839.         char *record;                           Record name
  840.         char *field;                            Key field name
  841.         char *target;                           Destination pointer
  842.         
  843.  
  844.     Description
  845.         This function will retreive the current record of a specific record
  846.         type using the currency table for that record.  The record must be
  847.         retreived using a key field.
  848.  
  849.  
  850.     Example
  851.  
  852.         #include "dbmgr.h"
  853.  
  854.         Function()
  855.             {
  856.             struct CustomerTable customer;
  857.  
  858.             DbRecordGetCurrent( "customer", "zipcode", (char *)&customer);
  859.             }
  860.  
  861.  
  862.  
  863.  
  864.     DbRecordGetFirst
  865.     -------------------------------------------------------------------------
  866.  
  867.  
  868.  
  869.     int DbRecordGetFirst( record, field, target);
  870.         char *record;                           Record name
  871.         char *field;                            Key field name
  872.         char *target;                           Destination pointer
  873.         
  874.  
  875.     Description
  876.         Get the first record of a certain record type.  The record must be
  877.         retreived using a key field.
  878.  
  879.  
  880.     Example
  881.  
  882.         #include "dbmgr.h"
  883.  
  884.         Function()
  885.             {
  886.             struct CustomerTable customer;
  887.  
  888.             if( DbRecordGetFirst( "customer", "zipcode", (char *)&customer))
  889.                 printf( "Error: customer not found\n");
  890.             }
  891.  
  892.  
  893.  
  894.  
  895.     DbRecordGetLast
  896.     -------------------------------------------------------------------------
  897.  
  898.  
  899.  
  900.     int DbRecordGetLast( record, field, target);
  901.         char *record;                           Record name
  902.         char *field;                            Key field name
  903.         char *target;                           Destination pointer
  904.         
  905.  
  906.     Description
  907.         Get the last record of a certain record type.  The record must be
  908.         retreived using a key field.
  909.  
  910.  
  911.     Example
  912.  
  913.         #include "dbmgr.h"
  914.  
  915.         Function()
  916.             {
  917.             struct CustomerTable customer;
  918.  
  919.             if( DbRecordGetLast( "customer", "zipcode", (char *)&customer))
  920.                 printf( "Error: customer not found\n");
  921.             }
  922.  
  923.  
  924.  
  925.  
  926.     DbRecordGetNext
  927.     -------------------------------------------------------------------------
  928.  
  929.  
  930.  
  931.     int DbRecordGetNext( record, field, target);
  932.         char *record;                           Record name
  933.         char *field;                            Key field name
  934.         char *target;                           Destination pointer
  935.         
  936.  
  937.     Description
  938.         Get the next record of a certain record type.  The record must be
  939.         retreived using a key field.
  940.  
  941.  
  942.     Example
  943.  
  944.         #include "dbmgr.h"
  945.  
  946.         Function()
  947.             {
  948.             struct CustomerTable customer;
  949.  
  950.             if( DbRecordGetNext( "customer", "zipcode", (char *)&customer))
  951.                 printf( "Error: customer not found\n");
  952.             }
  953.  
  954.  
  955.  
  956.  
  957.     DbRecordGetPrev
  958.     -------------------------------------------------------------------------
  959.  
  960.  
  961.  
  962.     int DbRecordGetPrev( record, field, target);
  963.         char *record;                           Record name
  964.         char *field;                            Key field name
  965.         char *target;                           Destination pointer
  966.         
  967.  
  968.     Description
  969.         Get the previous record of a certain record type.  The record must be
  970.         retreived using a key field.
  971.  
  972.  
  973.     Example
  974.  
  975.         #include "dbmgr.h"
  976.  
  977.         Function()
  978.             {
  979.             struct CustomerTable customer;
  980.  
  981.             if( DbRecordGetPrev( "customer", "zipcode", (char *)&customer))
  982.                 printf( "Error: customer not found\n");
  983.             }
  984.  
  985.  
  986.  
  987.  
  988.     DbRecordUpdate
  989.     -------------------------------------------------------------------------
  990.  
  991.  
  992.  
  993.     int DbRecordUpdate( record, source);
  994.         char *record;                           Record name
  995.         char *source;                           Source pointer
  996.         
  997.  
  998.     Description
  999.         Update a record in the database.  The record you wish to update must
  1000.         be current.
  1001.  
  1002.  
  1003.     Example
  1004.  
  1005.         #include "dbmgr.h"
  1006.  
  1007.         Function()
  1008.             {
  1009.             long accountNbr = 1000L;
  1010.             struct CustomerTable customer;
  1011.  
  1012.  
  1013.             if( DbRecordGetByKey( "customer", "acctnbr", (char *)&customer,
  1014.                 (char *)&accountNbr))
  1015.                 {
  1016.                 printf( "Error: getting customer record\n");
  1017.                 }
  1018.  
  1019.                 .
  1020.                 .
  1021.                 .
  1022.             modify record
  1023.                 .
  1024.                 .
  1025.                 .
  1026.  
  1027.             if( DbRecordUpdate( "customer", (char *)&customer))
  1028.                 printf( "Error: updating customer record);
  1029.             }
  1030.  
  1031.  
  1032.  
  1033.  
  1034.     DbRecordUpdCurrency
  1035.     -------------------------------------------------------------------------
  1036.  
  1037.  
  1038.  
  1039.     int DbRecordUpdCurrency( record, currency);
  1040.         char *record;                           Record name
  1041.         char *currency;                         Ptr to currency record
  1042.  
  1043.  
  1044.     Description
  1045.  
  1046.         This function allows you to update the current position (currency) of
  1047.         a specific record type.
  1048.  
  1049.  
  1050.     Example
  1051.  
  1052.         #include "dbmgr.h"
  1053.  
  1054.         Function()
  1055.             {
  1056.             struct currency_index currency;
  1057.  
  1058.             DbRecordGetCurrency( (char *)¤cy, "customer");
  1059.  
  1060.                 .
  1061.                 .
  1062.                 .
  1063.             processing
  1064.                 .
  1065.                 .
  1066.                 .
  1067.  
  1068.             DbRecordUpdCurrency( (char *)¤cy, "customer");
  1069.             }
  1070.  
  1071.  
  1072.  
  1073.  
  1074.     DbSetAdd
  1075.     -------------------------------------------------------------------------
  1076.  
  1077.  
  1078.  
  1079.     int DbSetAdd( owner, member);
  1080.         char *owner;                            Owner name
  1081.         char *member;                           Member name
  1082.         
  1083.  
  1084.     Description
  1085.         Create a set connection between two records.  Both records must have
  1086.         currency before creating the set connection.
  1087.  
  1088.  
  1089.     Example
  1090.  
  1091.         #include "dbmgr.h"
  1092.  
  1093.         Function()
  1094.             {
  1095.             long accountNbr = 1000L;
  1096.  
  1097.             DbRecordFindByKey( "customer", "acctnbr", (char *)&accountNbr);
  1098.             DbFindRecordbyKey( "address", "zipcode", "99999");
  1099.  
  1100.             if( DbSetAdd( "customer", "address"))
  1101.                 printf( "Error: set connection not created\n");
  1102.             }
  1103.  
  1104.  
  1105.  
  1106.  
  1107.     DbSetDelete
  1108.     -------------------------------------------------------------------------
  1109.  
  1110.  
  1111.  
  1112.     int DbSetDelete( owner, member);
  1113.         char *owner;                            Owner name
  1114.         char *member;                           Member name
  1115.         
  1116.  
  1117.     Description
  1118.         Remove a set connection between two records.  Both records must have
  1119.         currency before removing the set connection.
  1120.  
  1121.  
  1122.     Example
  1123.  
  1124.         #include "dbmgr.h"
  1125.  
  1126.         Function()
  1127.             {
  1128.             long accountNbr = 1000L;
  1129.  
  1130.             DbRecordFindByKey( "customer", "acctnbr", (char *)&accountNbr);
  1131.             DbFindRecordbyKey( "address", "zipcode", "99999");
  1132.  
  1133.             if( DbSetDelete( "customer", "address"))
  1134.                 printf( "Error: set connection not deleted\n");
  1135.             }
  1136.  
  1137.  
  1138.  
  1139.  
  1140.     DbSetFindFirst
  1141.     -------------------------------------------------------------------------
  1142.  
  1143.  
  1144.  
  1145.     int DbSetFindFirst( owner, member);
  1146.         char *owner;                            Owner name
  1147.         char *member;                           Member name
  1148.         
  1149.  
  1150.     Description
  1151.         Find the first set connection between an owner and member record.
  1152.  
  1153.  
  1154.     Example
  1155.  
  1156.         #include "dbmgr.h"
  1157.  
  1158.         Function()
  1159.             {
  1160.             long accountNbr = 1000L;
  1161.  
  1162.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1163.  
  1164.             if( DbSetFindFirst( "customer", "address"))
  1165.                 printf( "Error: set connection not found\n");
  1166.             }
  1167.  
  1168.  
  1169.  
  1170.  
  1171.     DbSetFindLast
  1172.     -------------------------------------------------------------------------
  1173.  
  1174.  
  1175.  
  1176.     int DbSetFindLast( owner, member);
  1177.         char *owner;                            Owner name
  1178.         char *member;                           Member name
  1179.         
  1180.  
  1181.     Description
  1182.         Find the last set connection between an owner and member record.
  1183.  
  1184.  
  1185.     Example
  1186.  
  1187.         #include "dbmgr.h"
  1188.  
  1189.         Function()
  1190.             {
  1191.             long accountNbr = 1000L;
  1192.  
  1193.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1194.  
  1195.             if( DbSetFindLast( "customer", "address"))
  1196.                 printf( "Error: set connection not found\n");
  1197.             }
  1198.  
  1199.  
  1200.  
  1201.  
  1202.     DbSetFindNext
  1203.     -------------------------------------------------------------------------
  1204.  
  1205.  
  1206.  
  1207.     int DbSetFindNext( owner, member);
  1208.         char *owner;                            Owner name
  1209.         char *member;                           Member name
  1210.         
  1211.  
  1212.     Description
  1213.         Find the next set connection between an owner and member record.
  1214.  
  1215.  
  1216.     Example
  1217.  
  1218.         #include "dbmgr.h"
  1219.  
  1220.         Function()
  1221.             {
  1222.             long accountNbr = 1000L;
  1223.  
  1224.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1225.  
  1226.             if( DbSetFindFirst( "customer", "address"))
  1227.                 printf( "Error: set connection not found\n");
  1228.             if( DbSetFindNext( "customer", "address"))
  1229.                 printf( "Error: set connection not found\n");
  1230.             }
  1231.  
  1232.  
  1233.  
  1234.  
  1235.     DbSetFindPrev
  1236.     -------------------------------------------------------------------------
  1237.  
  1238.  
  1239.  
  1240.     int DbSetFindPrev( owner, member);
  1241.         char *owner;                            Owner name
  1242.         char *member;                           Member name
  1243.         
  1244.  
  1245.     Description
  1246.         Find the previous set connection between an owner and member record.
  1247.  
  1248.  
  1249.     Example
  1250.  
  1251.         #include "dbmgr.h"
  1252.  
  1253.         Function()
  1254.             {
  1255.             long accountNbr = 1000L;
  1256.  
  1257.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1258.  
  1259.             if( DbSetFindLast( "customer", "address"))
  1260.                 printf( "Error: set connection not found\n");
  1261.             if( DbSetFindPrev( "customer", "address"))
  1262.                 printf( "Error: set connection not found\n");
  1263.             }
  1264.  
  1265.  
  1266.  
  1267.  
  1268.     DbSetGetFirst
  1269.     -------------------------------------------------------------------------
  1270.  
  1271.  
  1272.  
  1273.     int DbSetGetFirst( owner, member, target);
  1274.         char *owner;                            Owner name
  1275.         char *member;                           Member name
  1276.         char *target;                           Destination pointer
  1277.         
  1278.  
  1279.     Description
  1280.         Get the first set connection between an owner and member record.
  1281.         The member record will be retrieved.
  1282.  
  1283.  
  1284.     Example
  1285.  
  1286.         #include "dbmgr.h"
  1287.  
  1288.         Function()
  1289.             {
  1290.             long accountNbr = 1000L;
  1291.             struct AddressTable address;
  1292.  
  1293.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1294.  
  1295.             if( DbSetGetFirst( "customer", "address", (char *)&address))
  1296.                 printf( "Error: set not found\n");
  1297.             }
  1298.  
  1299.  
  1300.  
  1301.  
  1302.     DbSetGetLast
  1303.     -------------------------------------------------------------------------
  1304.  
  1305.  
  1306.  
  1307.     int DbSetGetLast( owner, member, target);
  1308.         char *owner;                            Owner name
  1309.         char *member;                           Member name
  1310.         char *target;                           Destination pointer
  1311.         
  1312.  
  1313.     Description
  1314.         Get the last set connection between an owner and member record.
  1315.         The member record will be retrieved.
  1316.  
  1317.  
  1318.     Example
  1319.  
  1320.         #include "dbmgr.h"
  1321.  
  1322.         Function()
  1323.             {
  1324.             long accountNbr = 1000L;
  1325.             struct AddressTable address;
  1326.  
  1327.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1328.  
  1329.             if( DbSetGetLast( "customer", "address", (char *)&address))
  1330.                 printf( "Error: set not found\n");
  1331.             }
  1332.  
  1333.  
  1334.  
  1335.  
  1336.     DbSetGetNext
  1337.     -------------------------------------------------------------------------
  1338.  
  1339.  
  1340.  
  1341.     int DbSetGetNext( owner, member, target);
  1342.         char *owner;                            Owner name
  1343.         char *member;                           Member name
  1344.         char *target;                           Destination pointer
  1345.         
  1346.  
  1347.     Description
  1348.         Get the next set connection between an owner and member record.
  1349.         The member record will be retrieved.
  1350.  
  1351.  
  1352.     Example
  1353.  
  1354.         #include "dbmgr.h"
  1355.  
  1356.         Function()
  1357.             {
  1358.             long accountNbr = 1000L;
  1359.             struct AddressTable address;
  1360.  
  1361.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1362.  
  1363.             if( DbSetGetFirst( "customer", "address", (char *)&address))
  1364.                 printf( "Error: set not found\n");
  1365.             if( DbSetGetNext( "customer", "address", (char *)&address))
  1366.                 printf( "Error: set not found\n");
  1367.             }
  1368.  
  1369.  
  1370.  
  1371.  
  1372.     DbSetGetOwner
  1373.     -------------------------------------------------------------------------
  1374.  
  1375.  
  1376.  
  1377.     int DbSetGetOwner( owner, member, target);
  1378.         char *owner;                            Owner name
  1379.         char *member;                           Member name
  1380.         char *target;                           Destination pointer
  1381.         
  1382.  
  1383.     Description
  1384.         Get the owner of a record.  A set connection must exist between owner
  1385.         and member.  The owner record will be retrieved.
  1386.  
  1387.  
  1388.     Example
  1389.  
  1390.         #include "dbmgr.h"
  1391.  
  1392.         Function()
  1393.             {
  1394.             struct CustomerTable customer;
  1395.             struct AddressTable address;
  1396.  
  1397.             DbFindRecordbyKey( "address", "zipcode", "99999");
  1398.  
  1399.             if( DbSetGetOwner( "customer", "address", (char *)&customer))
  1400.                 printf( "Error: set not found\n");
  1401.             }
  1402.  
  1403.  
  1404.  
  1405.  
  1406.     DbSetGetPrev
  1407.     -------------------------------------------------------------------------
  1408.  
  1409.  
  1410.  
  1411.     int DbSetGetPrev( owner, member, target);
  1412.         char *owner;                            Owner name
  1413.         char *member;                           Member name
  1414.         char *target;                           Destination pointer
  1415.         
  1416.  
  1417.     Description
  1418.         Get the previous set connection between an owner and member record.
  1419.         The member record will be retrieved.
  1420.  
  1421.  
  1422.     Example
  1423.  
  1424.         #include "dbmgr.h"
  1425.  
  1426.         Function()
  1427.             {
  1428.             long accountNbr = 1000L;
  1429.             struct AddressTable address;
  1430.  
  1431.             DbFindRecordbyKey( "customer", "acctnbr", (char *)&accountNbr);
  1432.  
  1433.             if( DbSetGetLast( "customer", "address", (char *)&address))
  1434.                 printf( "Error: set not found\n");
  1435.             if( DbSetGetPrev( "customer", "address", (char *)&address))
  1436.                 printf( "Error: set not found\n");
  1437.             }
  1438.  
  1439.  
  1440.                                     Errors
  1441.  
  1442.  
  1443.  
  1444.     Every database call has the potential for errors to occur.  A return
  1445.     value of 0 indicates no error has occured.
  1446.  
  1447.  
  1448.     Error returns
  1449.     -------------
  1450.     E_INVALIDCASE       -2
  1451.     E_DOS               -1
  1452.     E_NORECNAME         1
  1453.     E_NOFLDNAME         2
  1454.     E_INVALIDSET        3
  1455.     E_NOTAKEY           4
  1456.     E_NOTFOUND          5
  1457.     E_NEXTGUESS         6
  1458.     E_NOCURRENT         7
  1459.     E_NONEXT            8
  1460.     E_NOPREV            9
  1461.     E_NOMEMBER          10
  1462.     E_NOOWNER           11
  1463.  
  1464.  
  1465.  
  1466.     E_INVALIDCASE   An internal database error. Should this error occur,
  1467.                     contact technical support.
  1468.     E_DOS           A DOS error has occured.  The error number is in the
  1469.                     global "errno".
  1470.     E_NORECNAME     The record name passed is not valid.
  1471.     E_NOFLDNAME     The field name passed is not valid.
  1472.     E_INVALIDSET    The set name combination passed is not a valid set.
  1473.                     The DDL keyword CONNECT must be used to enable set
  1474.                     connections between records to occur.
  1475.     E_NOTAKEY       Field name passed is not a key field.
  1476.     E_NOTFOUND      Record or set not found.
  1477.     E_NEXTGUESS     The key value passed was not found but the next closest
  1478.                     match was returned.
  1479.     E_NOCURRENT     There is no current record for the record(s) specified.
  1480.                     i.e You are trying to do a DbRecordGetNext before doing
  1481.                         a DbRecordGetFirst.
  1482.     E_NONEXT        Next record or set not found.
  1483.     E_NOPREV        Previous record or set not found.
  1484.     E_NOMEMBER      Owner record has no member.
  1485.     E_NOOWNER       Member record has no owner.
  1486.  
  1487.  
  1488.  
  1489.  
  1490.                              Registration Notification
  1491.  
  1492.  
  1493.  
  1494.  
  1495.     CDB is copyrighted and is the property of Daytris.
  1496.  
  1497.     CDB is distributed as User-Supported software.  Commercial use or
  1498.     development using this product requires you to register.  Registering
  1499.     your copy of the software helps the authors continue to provide
  1500.     professional quality software at very reasonable prices.
  1501.  
  1502.     You have a royalty-free right to reproduce and distribute executable
  1503.     files created using the CDB libraries after registration.
  1504.  
  1505.     The Complete Registration is $45.00 and includes the full library source
  1506.     code, all utility source code, make files, royalty-free use of library
  1507.     functions, unlimited technical support, and low-cost upgrades.
  1508.  
  1509.     A Basic Registration is also available for $35.00 which includes all of
  1510.     the above excluding source code.  With the Basic Registration, the user
  1511.     will receive the CDB libraries for the memory model(s) and compiler(s)
  1512.     of their choice.
  1513.  
  1514.     Non-U.S. orders need to include $5.00 extra to cover additional shipping
  1515.     and handling charges.  Checks and money orders must be drawn on a U.S.
  1516.     bank.  Please send all payments payable in U.S. Dollars.
  1517.  
  1518.  
  1519.  
  1520.     Disclaimer.
  1521.  
  1522.     The authors claim no responsibility for any damages caused by the use or
  1523.     misuse of this product.  This product is distributed "as is" with no
  1524.     warranty expressed or implied.  The authors will not be responsible for
  1525.     any losses incurred, either directly or indirectly, by the use of this
  1526.     product. The authors reserve the right to make modifications at any
  1527.     time.  Prices are subject to change without notice.
  1528.  
  1529.  
  1530.     ---------------------------------------------------------------------
  1531.  
  1532.                            Registration Form for CDB
  1533.  
  1534.  
  1535.      
  1536.     Name:              _________________________________________________
  1537.  
  1538.     Company:           _________________________________________________
  1539.  
  1540.     Address:           _________________________________________________
  1541.  
  1542.     City, State, Zip:  _________________________________________________
  1543.  
  1544.     Telephone:         _________________________________________________
  1545.  
  1546.     Country:           _________________________________________________
  1547.  
  1548.     E-Mail Address:    _________________________________________________
  1549.  
  1550.  
  1551.     Source Code Media:
  1552.  
  1553.     5 1/4 " diskette   ___
  1554.  
  1555.     3 1/2 " diskette   ___
  1556.  
  1557.  
  1558.     A. Basic Registration (includes libraries only)
  1559.  
  1560.     Memory Model(s):   ___ Small   ___ Medium   ___ Compact   ___ Large
  1561.  
  1562.     Compiler(s):       ___ MSC     ___ Turbo C
  1563.  
  1564.     Number of Copies   ___  X  $35  = ______________
  1565.  
  1566.  
  1567.     B. Complete Registration (includes full library source)
  1568.  
  1569.     Number of Copies   ___  X  $45  = ______________
  1570.  
  1571.      
  1572.  
  1573.     COMMENTS: Please feel free to add your thoughts or suggestions!
  1574.  
  1575.     _____________________________________________________________________
  1576.  
  1577.     _____________________________________________________________________
  1578.  
  1579.     _____________________________________________________________________
  1580.  
  1581.      
  1582.     Make Checks payable to:     Daytris
  1583.  
  1584.     Mail to:                    Daytris
  1585.                                 81 Bright Street, Suite 1E
  1586.                                 Jersey City, NJ  07302
  1587.