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

Abstract
I/O
Examples
Particulars
Required Reading
Version
Index_Entries

Abstract


   CSPICE_EKPSEL parses the SELECT clause of an EK query, returning
   full particulars concerning each selected item. Use the routine
   to determine at runtime the attributes of the columns named in
   the select clause.

   For important details concerning this module's function, please refer to
   the CSPICE routine ekpsel_c.

I/O

   
   Given the EK query string 'query', the call:
   
      cspice_ekpsel, query, n, xbegs, xends, xtypes, $
                     xclass, tabs, cols, error, `errmsg'
   
   returns:
      
      n        a scalar integer indicating the number of items 
               in SELECT clause of query. 
               
      xbegs    a scalar integer array containing the positions of expressions 
               in SELECT clause.
               
      xends    a scalar integer array containing end positions of expressions 
               in SELECT clause. 
               
      xtypes   a scalar integer array containing the data type code
               of the expressions. The possible return values:
   
                    0 indicates SPICE_CHR, for a character expression
                    1 indicates SPICE_DP, for a double precision expression
                    2 indicates SPICE_INT, for an integer expression
                    3 indicates SPICE_TIME, for a time (double precision) 
                                            expression 
   
      xclass   the classes of expressions.
      
      tabs     a vector of strings containing the names of tables 
               qualifying SELECT columns.
               
      cols     a vector of strings containing the names of columns
               in SELECT clause of query.
               
      error    a scalar boolean indicating whether an error occurred (true) 
               in the select query or not (false).
               
      errmsg   a scalar string returning the parse error message if 
               'error' equals TRUE.
   

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.

   
      ;;
      ;; Load an EK file and a meta kernel listing a
      ;; leapseconds file.
      ;;
      cspice_furnsh, 'standard.tm'
      cspice_furnsh, 'test_file.ek'
   
      ;;
      ;; the select clause of the query string: 
      ;;
      ;;   Select c_col_1, d_col_1, i_col_1, t_col_1
      ;;
      query = "Select c_col_1, d_col_1, i_col_1, t_col_1 from " + $
              " scalar_2 order by row_no"
   
      ;;
      ;; Define the types of EK columns.
      ;;
      SPICE_CHR  = 0
      SPICE_DP   = 1
      SPICE_INT  = 2
      SPICE_TIME = 3 
   
      cspice_ekpsel, query, n, xbegs, xends, xtypes, xclass, $
                     tabs , cols , error , errmsg
                                  
      if ( error ) then begin
         print, 'Error cspice_ekpsel: ' + errmsg
      endif
      
      
      ;;
      ;; Call cspice_ekfind with the query string.
      ;;   
      cspice_ekfind, query, nmrows, error, errmsg
      
      if ( error ) then begin
         print, 'Error cspice_ekfind: ', errmsg
      endif
   
      ;;
      ;; Use the appropriate fetch routine as needed for the type
      ;; of data in each column.
      ;;
      for row = 0, (nmrows-1) do begin
         
         for col = 0, (n-1) do begin
   
            print, 'For row ', row, ' col ', col
   
            case  xtypes[col] of
   
               SPICE_CHR  : begin
   
                  cspice_ekgc, col, row, 0, cdata, isnull, found
                               
                  if( ~isnull) then begin
                     print, '   Character data: ', cdata
                  endif
                                 
                  end
   
               SPICE_INT  : begin
   
                  cspice_ekgi, col, row, 0, idata, isnull, found
      
                  if( ~isnull) then begin
                     print, '   Integer data: ', idata
                  endif
      
                  end
                               
               SPICE_DP   : begin
       
                  cspice_ekgd, col, row, 0, ddata, isnull, found
      
                  if( ~isnull) then begin
                     print, '   DP data: ', ddata
                  endif
   
                  end
                               
               SPICE_TIME : begin
      
                  cspice_ekgd, col, row, 0, ddata, isnull, found
      
                  if( ~isnull) then begin
                     cspice_et2utc, ddata, "C", 3, utcstr
                     print, '   Time data: ', utcstr
                  endif
   
                  end
                              
               else: print, 'Unknown value type'
   
               endcase
   
            endfor
      
         endfor
   
   IDL outputs (for test_file.ek):
   
      For row        0 col        0
         Character data: SEG_2_C_COL_1_ROW_1
      For row        0 col        1
         DP data:       -2000001.0
      For row        0 col        2
         Integer data:      2000001
      For row        0 col        3
         Time data: 1999 DEC 09 08:25:34.817
      For row        1 col        0
         Character data: SEG_2_C_COL_1_ROW_2
      For row        1 col        1
         DP data:       -2000002.0
      For row        1 col        2
         Integer data:      2000002
      For row        1 col        3
         Time data: 1999 DEC 09 08:25:33.817
   
      ... continue ...
   
      For row       19 col        0
         Character data: SEG_2_C_COL_1_ROW_20
      For row       19 col        1
         DP data:       -2000020.0
      For row       19 col        2
         Integer data:      2000020
      For row       19 col        3
         Time data: 1999 DEC 09 08:25:15.817

Particulars


   None.

Required Reading


   ICY.REQ
   EK.REQ

Version



   -Icy Version 1.0.1, 04-FEB-2008, EDW (JPL)
   
      Edited example code to replace 
      
         not isnull
      
      with
      
         ~isnull

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

Index_Entries

 
   parse select clause of EK query 
 



Wed Apr  5 17:58:00 2017