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

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_EKDELR deletes a specified record from a specified EK
   segment.

I/O


   Given:

      handle   a file handle of an EK open for write access.

               help, handle
                  LONG = Scalar

      segno    the number of the segment from which to delete the specified
               record.

               help, segno
                  LONG = Scalar

      recno    the index of the record to delete.

               help, recno
                  LONG = Scalar

               `recno' must be in the range 0 : NREC-1, where NREC is the
               number of records in the segment prior to the insertion.

   the call:

      cspice_ekdelr, handle, segno, recno

   deletes record `recno' in EK segment `segno' from the EK referred
   to by `handle'.

Parameters


   None.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

   1) The following program demonstrates how to delete a specified
      record from a given EK segment.

      The program creates a new EK, sets up the table, column names
      and declarations for a segment, and adds 100 records of simple
      integer data values. After closing and reopening the file,
      every other record is deleted.

      Before and after deleting records, a summary of the EK is
      produced.

      Example code begins here.


      PRO ekdelr_ex1

         ;;
         ;; Constants
         ;;
         SPICETRUE        = 1B
         SPICEFALSE       = 0B
         SPICE_EK_CNAMSZ  = 32
         SPICE_EK_CSTRLN  = SPICE_EK_CNAMSZ + 1
         SPICE_EK_TNAMSZ  = 64
         SPICE_EK_TSTRLN  = SPICE_EK_TNAMSZ + 1
         EKNAME           = "ekdelr_ex1.bdb"
         IFNAME           = "Test EK"
         NCOLS            = 1
         NROWS            = 100
         NRESVC           = 0
         TABLE            = "SCALAR_DATA"
         MAXVAL           = 10

         ;;
         ;; Declare memory for the column data.
         ;;
         ivals  = intarr( MAXVAL )

         ;;
         ;; Open a new EK file.  For simplicity, we won't
         ;; reserve space for the comment area, so the
         ;; number of reserved comment characters is zero.
         ;; The constant IFNAME is the internal file name.
         ;;
         if ( cspice_exists (EKNAME) ) then begin
            file_delete, EKNAME
         endif

         ;;
         ;; Create the new EK.
         ;;
         cspice_ekopn, EKNAME, IFNAME, NRESVC, handle

         ;;
         ;; Set up the table and column names and declarations
         ;; for the SCALAR_DATA segment.
         ;;
         cdecls = strarr(NCOLS)
         cnames = strarr(NCOLS)

         cnames[0] = "INT_COL_1"
         cdecls[0] = "DATATYPE = INTEGER, INDEXED  = TRUE, " +$
                     "NULLS_OK = TRUE"


         ;;
         ;; Start the segment.
         ;;
         cspice_ekbseg, handle, TABLE, NCOLS, cnames, cdecls, segno

         ;;
         ;; Add NROWS simple data values.
         ;;
         for i = 0, (NROWS-1) do begin

            cspice_ekappr, handle, segno, recno

            isnull   =  SPICEFALSE

            ivals[0] = i
            cspice_ekacei, handle, segno,  recno,  cnames[0], $
                           1,      ivals,  isnull

         endfor

         ;;
         ;; Summarize the EK.
         ;;
         cspice_ekssum, handle,  segno, sum_nrow, sum_ncol, $
                        tabnam, cnames, cclass  , dtype   , $
                        size  , strlen, indexd  , nullok

         ;;
         ;; Display the number of rows and columns in the EK.
         ;;
         print, 'Number of rows before delete   : ', sum_nrow
         print, 'Number of columns before delete: ', sum_ncol

         ;; End the file.
         ;;
         cspice_ekcls, handle

         ;;
         ;; Update the EK: delete half the records
         ;; via a cspice_ekdelr call. First, open the file for
         ;; write access.
         ;;
         cspice_ekopw, EKNAME, handle

         ;;
         ;; Perform the delete. Delete every other record.
         ;;
         for i = 0,  ( (NROWS/2) - 1) do begin
            cspice_ekdelr, handle, 0, i
         endfor

         ;;
         ;; Summarize the EK.
         ;;
         cspice_ekssum, handle,  segno, sum_nrow, sum_ncol,  $
                        tabnam, cnames, cclass  , dtype   ,  $
                        size  , strlen, indexd  , nullok

         ;;
         ;; Display the number of rows and columns in the EK.
         ;;
         print, 'Number of rows after delete    : ', sum_nrow
         print, 'Number of columns after delete : ', sum_ncol

         ;;
         ;; End the file.
         ;;
         cspice_ekcls, handle

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Number of rows before delete   :          100
      Number of columns before delete:            1
      Number of rows after delete    :           50
      Number of columns after delete :            1


      Note that after run completion, a new EK exists in the output
      directory.

Particulars


   This routine operates by side effects: it deletes a record
   from an EK segment. Deleting a record implies:

      1) All column entries in the record are deleted.

      2) Link counts are decremented for data pages containing
         column entries in the record to be deleted. Pages whose
         link counts drop to zero are freed.

      3) All column indexes are updated for the parent segment.

      4) The link count is decremented for the page containing the
         record pointer structure of the record to be deleted. If
         the link count drops to zero, the page is freed.

      5) The pointer to the deleted record is deleted from the
         record tree for the parent segment.

      6) The segment's metadata is updated to reflect the new
         record count.

Exceptions


   1)  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.

   5)  If any of the input arguments, `handle', `segno' or `recno',
       is undefined, an error is signaled by the IDL error handling
       system.

   6)  If any of the input arguments, `handle', `segno' or `recno',
       is not of the expected type, or it does not have the expected
       dimensions and size, an error is signaled by the Icy
       interface.

Files


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

Restrictions


   None.

Required_Reading


   ICY.REQ
   EK.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 25-AUG-2021 (JDR)

       Edited the header to comply with NAIF standard. Added
       example's problem statement and a note after the example's
       output. Updated code example to output the number of columns
       before and after delete operations.

       Added -Parameters, -Particulars, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections.

       Removed reference to the routine's corresponding CSPICE header from
       -Abstract section.

       Added arguments' type and size information in the -I/O section.

   -Icy Version 1.0.0, 16-JUN-2003 (EDW)

Index_Entries


   delete record from an EK segment



Fri Dec 31 18:43:04 2021