ekinsr_c |
Table of contents
Procedureekinsr_c ( EK, insert record into segment ) void ekinsr_c ( SpiceInt handle, SpiceInt segno, SpiceInt recno ) AbstractAdd a new, empty record to a specified E-kernel segment at a specified index. Required_ReadingEK KeywordsEK UTILITY Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- handle I File handle. segno I Segment number. recno I Record number. Detailed_Inputhandle 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_OutputNone. See the -Particulars section for a description of the effect of this routine. ParametersNone. Exceptions1) If `handle' is invalid, an error is signaled by a routine in the call tree of this routine. The file will not be modified. 2) If `segno' is out of range, the error SPICE(INVALIDINDEX) is signaled by a routine in the call tree of this routine. The file will not be modified. 3) If `recno' is out of range, the error SPICE(INVALIDINDEX) is signaled by a routine in the call tree of this routine. The file will not be modified. 4) If an I/O error occurs while reading or writing the indicated file, the error is signaled by a routine in the call tree of this routine. The file may be corrupted. FilesSee the EK Required Reading for a discussion of the EK file format. ParticularsThis 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 ekaceX_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. Examples1) 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 ekaceX_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 ); RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) Version-CSPICE Version 1.0.1, 24-NOV-2021 (JDR) Edited the header to comply with NAIF standard. -CSPICE Version 1.0.0, 09-JAN-2002 (NJB) Index_Entriesinsert record into EK segment |
Fri Dec 31 18:41:05 2021