Index Page
ekinsr_c
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 

Procedure
Abstract
Required_Reading
Keywords
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version
Index_Entries

Procedure

   void ekinsr_c ( SpiceInt  handle,
                   SpiceInt  segno,
                   SpiceInt  recno ) 

Abstract

 
   Add a new, empty record to a specified E-kernel segment at 
   a specified index. 
 

Required_Reading

 
   EK 
 

Keywords

 
   EK
   UTILITY 
 

Brief_I/O

 
   Variable  I/O  Description 
   --------  ---  -------------------------------------------------- 
   handle     I   File handle. 
   segno      I   Segment number. 
   recno      I   Record number. 
 

Detailed_Input

 
   handle         is a file handle of an EK open for write access. 
 
   segno          is the number of the segment to which the record 
                  is to be added. 
 
   recno          is the index of the new record.  recno must be 
                  in the range 0 : NREC, where NREC is the 
                  number of records in the segment prior to the 
                  insertion.  If recno is equal to NREC, the 
                  new record is appended.  Otherwise, the new 
                  record has the ordinal position specified by 
                  recno, and the records previously occupying 
                  positions recno : NREC-1 have their indices 
                  incremented by 1. 
 

Detailed_Output

 
   None.  See the $Particulars section for a description of the 
   effect of this routine. 
 

Parameters

 
   None. 
 

Exceptions

 
   1)  If handle is invalid, the error will be diagnosed by routines 
       called by this routine.  The file will not be modified. 
 
   2)  If segno is out of range, the error SPICE(INVALIDINDEX) 
       will be signaled.  The file will not be modified. 
 
   3)  If recno is out of range, the error SPICE(INVALIDINDEX) 
       will be signaled.  The file will not be modified. 
 
   4)  If an I/O error occurs while reading or writing the indicated 
       file, the error will be diagnosed by routines called by this 
       routine.  The file may be corrupted. 
 

Files

 
   See the EK Required Reading for a discussion of the EK file 
   format. 
 

Particulars

 
   This routine operates by side effects:  It adds a new, empty 
   record structure to an EK segment at a specified ordinal position. 
 
   After a record has been inserted into a segment by this routine, 
   the record must be populated with data using the ekace*_c 
   routines.  EKs are valid only when all of their column entries 
   are initialized. 
 
   To append a record to a segment, use the routine ekappr_c. 
 
   This routine cannot be used with the "fast write" suite of 
   routines.  See the EK Required Reading for a discussion of the 
   fast writers. 
 

Examples

 
   1)  Insert a record into a specified E-kernel segment at a 
       specified ordinal position. 
 
       Suppose we have an E-kernel named order_db.ek which contains 
       records of orders for data products.  The E-kernel has a 
       table called DATAORDERS that consists of the set of columns 
       listed below: 
 
          DATAORDERS 
 
             Column Name     Data Type 
             -----------     --------- 
             ORDER_ID        INTEGER 
             CUSTOMER_ID     INTEGER 
             LAST_NAME       CHARACTER*(*) 
             FIRST_NAME      CHARACTER*(*) 
             ORDER_DATE      TIME 
             COST            DOUBLE PRECISION 
 
       The order database also has a table of items that have been 
       ordered.  The columns of this table are shown below: 
 
          DATAITEMS 
 
             Column Name     Data Type 
             -----------     --------- 
             ITEM_ID         INTEGER 
             ORDER_ID        INTEGER 
             ITEM_NAME       CHARACTER*(*) 
             DESCRIPTION     CHARACTER*(*) 
             PRICE           DOUBLE PRECISION 
 
 
       We'll suppose that the file order_db.ek contains two segments, 
       the first containing the DATAORDERS table and the second 
       containing the DATAITEMS table. 
 
       If we wanted to insert a new record into the DATAORDERS 
       table in position 0, we'd make the following calls: 

 
         
 
            EKCLS ( HANDLE ) 
          #include "SpiceUsr.h"
              .
              . 
              . 
          /. 
          Open the database for write access.  This call is 
          made when the file already exists.  See ekopn_c for 
          an example of creating a new file. 
          ./
          ekopw_c ( "order_db.ek", &handle ); 
 
          /.
          Insert a new, empty record into the DATAORDERS 
          table at record number 0.  This moves the existing 
          records down, so the old record 0 becomes record 1, 
          and so on.  Recall that the DATAORDERS table 
          is in segment number 0. 
          ./ 
          recno = 0;
          segno = 0; 
 
          ekinsr_c ( handle, segno, recno );
 
          /.
          At this point, the new record is empty.  A valid EK 
          cannot contain empty records.  We fill in the data 
          here.  Data items are filled in one column at a time. 
          The order in which the columns are filled in is not 
          important.  We use the ekace*_c (add column entry) 
          routines to fill in column entries.  We'll assume 
          that no entries are null.  All entries are scalar, 
          so the entry size is 1. 
          ./ 
          isnull  =  SPICEFALSE;
          size    =  1; 
 
          /.
          The following variables will contain the data for 
          the new record. 
          ./
          ordid    =   10011; 
          custid   =   531;
          lname    =   "scientist"; 
          fname    =   "joe";
          odate    =   "1995-sep-20"; 
          cost     =   5000.;
 
          /.
          Note that the names of the routines called 
          correspond to the data types of the columns:  the 
          last letter of the routine name is C, I, or D, 
          depending on the data type.  Time values are 
          converted to ET for storage. 
          ./ 
          ekacei_c ( handle,  segno,  recno, "order_id", 
                     size,    ordid,  isnull             ); 
 
          ekacei_c ( handle,  segno,  recno, "customer_id", 
                     size,    custid, isnull              ); 
 
          ekacec_c ( handle,  segno,  recno, "last_name", 
                     size,    vallen, lname,  isnull      );
 
          ekacec_c ( handle,  segno,  recno, "first_name", 
                     size,    vallen, fname,  isnull      ); 
  
          utc2et_c ( odate,   &et );
 

          ekaced_c ( handle, segno,  recno, "order_date", 
                     size,   et,     isnull               ); 
 
          ekaced_c ( handle, segno,  recno, "cost", 
                     size,   cost,   isnull               ); 
 
          /.
          Close the file to make the update permanent. 
          ./
          ekcls_c ( handle );
 

Restrictions

 
   None. 
 

Literature_References

 
   None. 
 

Author_and_Institution

 
   N.J. Bachman   (JPL) 
 

Version

 
   -CSPICE Version 1.0.0, 09-JAN-2002 (NJB)

Index_Entries

 
   insert record into EK segment 
 

Link to routine ekinsr_c source file ekinsr_c.c

Wed Apr  5 17:54:33 2017