insert



Summary

#include <dataman/dataman.h>

insert(fmt,pos,idx_name);

int fmt, pos;
char *idx_name;

Description

The insert routine puts a new data record into a data base file. The routine determines the file that contains the record that the named index's MFRP points to and inserts format number fmt. If fmt is less than 1 or greater than the number of formats defined for the file a diagnostic is displayed and the routine halts. The pos argument is either of the manifest constants BEFORE or AFTER. The constant BEFORE inserts the new record prior to the MFRP and the constant AFTER inserts the record after. If the index currently points to no record, the diagnostic "initial GET not attempted" will appear and the routine will terminate. Otherwise the record that is currently in memory will be flushed, the new record, consisting of all blanks, will be inserted in the file, the MFRP moved to the new record, and the new blank record read into memory. All fields will be blank. The KP is unchanged.

Example

    #include <dataman/dataman.h>

    main(int argc,char *argv[])
    {


        key k_buff;
          ...
        move(k_buff,num_key);         /* build key */
        get(num_ix,num_key) else {    /* get rec */
            pause(1,1,"Key not on file");
            exit(0);
        }
        insert(1,BEFORE,num_ix);      /* insert new rec */
          ....
    }

«previous  next»