SpiceInt eknelt_c ( SpiceInt selidx,
SpiceInt row )
Return the number of elements in a specified column entry in
the current row.
EK
EK
Variable I/O Description
-------- --- --------------------------------------------------
selidx I Index of parent column in SELECT clause.
row I Row containing element.
The function returns the number of elements in entry in current row.
selidx is the SELECT clause index of the column to
fetch from. The range of selidx is 0 : (nsel-1)
inclusive, where nsel is the number of items in
the SELECT clause of the current query.
row is the index of the row containing the element.
This number refers to a member of the set of rows
matching a query. row must be in the range
0 : nmrows-1
where nmrows is the matching row count returned
by ekfind_c.
The function returns the number of elements in the column entry
belonging to the specified column in the current row.
Null entries in variable-size columns are considered to have size 1.
None.
1) If this routine is called when no E-kernels have been loaded,
the error SPICE(NOLOADEDFILES) is signalled.
2) If selidx is outside of the range established by the
last query passed to ekfind_c, the error SPICE(INVALIDINDEX)
will be signalled.
3) If row is outside of the range established by the
last query passed to ekfind_c, the error SPICE(INVALIDINDEX)
will be signalled.
At least one E-kernel must be loaded before queries may be passed to
the EK system via ekfind_c.
This routine is meant to be used in conjunction with the EK
fetch entry points ekgc_c, ekgd_c, and ekgi_c. This routine
allows the caller of those routines to determine appropriate
loop bounds to use to fetch each column entry in the current row.
1) Suppose the EK table TAB contains the following columns:
Column name Data Type Size
----------- --------- ----
IARRAY INT 10
DARRAY DP VARIABLE
CARRAY CHR VARIABLE
Suppose the query
QUERY = "SELECT IARRAY, DARRAY, CARRAY FROM TAB"
is issued to ekfind_c via the call
ekfind_c ( query, MSGLEN, &nmrows, &error, errmsg );
To fetch and dump column values from the rows that satisfy the
query, the loop below could be used. Note that we don't check
the FOUND flags returned by the fetch routines since we know
in advance how many elements are contained in each column
entry we fetch.
#include <stdio.h>
#include "SpiceUsr.h"
#define ISIZE 10
.
.
.
for ( row = 0; row < nmrows; row++ )
{
printf ( "\nROW = %d\n\n", row );
/.
Fetch values from column IARRAY in the current
row. Since IARRAY was the first column selected,
the selection index SELIDX is set to 0.
./
selidx = 0;
eltidx = 0;
isnull = SPICEFALSE;
while ( ( eltidx < ISIZE ) && ( !isnull ) )
{
/.
If the column entry is null, we'll be kicked
out of this loop after the first iteration.
./
ekgi_c ( selidx, row, eltidx,
ivals[eltidx], &isnull, &found );
eltidx++;
}
printf ( "\nCOLUMN = IARRAY\n\n" );
if ( isnull )
{
printf ( "<Null>\n" );
}
else
{
for ( i = 0; i < ISIZE; i++ )
{
printf ( "%d\n", ivals[i] );
}
}
/.
Fetch values from column DARRAY in the current
row. Since DARRAY contains variable-size array
elements, we call eknelt_c to determine how many
elements to fetch.
./
selidx = 1;
eltidx = 0;
nelt = eknelt_c ( selidx, row );
isnull = SPICEFALSE;
while ( ( eltidx < nelt ) && ( !isnull ) )
{
/.
If the column entry is null, we'll be kicked
out of this loop after the first iteration.
./
ekgd_c ( selidx, row, eltidx,
dvals[eltidx], &isnull, &found );
eltidx++;
}
printf ( "\nCOLUMN = DARRAY\n\n" );
if ( isnull )
{
printf ( "<Null>\n" );
}
else
{
for ( i = 0; i < nelt; i++ )
{
printf ( "%f\n", dvals[i] );
}
}
/.
Fetch values from column CARRAY in the current row.
./
selidx = 2;
eltidx = 0;
nelt = eknelt_c ( selidx, row );
isnull = SPICEFALSE;
while ( ( eltidx < nelt ) && ( !isnull ) )
{
/.
If the column entry is null, we'll be kicked
out of this loop after the first iteration.
CVLEN is the declared length of the strings in
the cvals array.
./
ekgc_c ( selidx, row, eltidx, CVLEN,
cvals[eltidx], &isnull, &found );
eltidx++;
}
printf ( "\nCOLUMN = CARRAY\n\n" );
if ( isnull )
{
printf ( "<Null>\n" );
}
else
{
for ( i = 0; i < nelt; i++ )
{
printf ( "%s\n", cvals[i] );
}
}
}
None.
None.
N.J. Bachman (JPL)
-CSPICE Version 1.1.0, 23-JUL-2001 (NJB)
Removed tab characters from source file.
-CSPICE Version 1.0.0, 24-FEB-1999 (NJB)
return the number of elements in a column entry
Link to routine eknelt_c source file eknelt_c.c
|