cursor/printANumberOfAdultsArroundRecord.c
static RDM_RETCODE printANumberOfAdultsArroundRecord (
RDM_CURSOR adult,
uint32_t num)
{
ADULT fAdult;
RDM_CURSOR adults = NULL;
uint32_t ii;
rc = rdm_cursorGetRowsAtPosition (adult, &adults);
for (ii = 0; rc == sOKAY && ii < num / 2; ii++)
{
rc = rdm_cursorMoveToPrevious (adults);
}
if (rc == sENDOFCURSOR)
{
rc = rdm_cursorMoveToNext (adults);
}
for (ii = 0; rc == sOKAY && ii < num; ii++)
{
rc = rdm_cursorReadRow (adults, &fAdult, sizeof (fAdult), NULL);
if (rc == sOKAY)
{
printf (
"Adult with id: %d and name: %s\n", fAdult.adult_id,
fAdult.adult_name);
rc = rdm_cursorMoveToNext (adults);
}
}
if (rc == sENDOFCURSOR)
rc = sOKAY;
rdm_cursorFree (adults);
return rc;
}
RDM_RETCODE rdm_cursorMoveToNext(RDM_CURSOR cursor)
Position a cursor to the next row in the collection.
struct RDM_CURSOR_S * RDM_CURSOR
Definition: rdmtypes.h:306
RDM_RETCODE rdm_cursorReadRow(RDM_CURSOR cursor, void *colValues, size_t bytesIn, size_t *bytesOut)
Read all columns from a row.
RDM_RETCODE rdm_cursorGetRowsAtPosition(RDM_CURSOR sourceCursor, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with rows from a table ordered by rowid and positioned to the same row as the...
@ sOKAY
Definition: rdmretcodetypes.h:97
RDM_RETCODE rdm_cursorMoveToPrevious(RDM_CURSOR cursor)
Position a cursor to the previous row in the collection.
RDM_RETCODE rdm_cursorFree(RDM_CURSOR cursor)
Free an RDM_CURSOR.
@ sENDOFCURSOR
Definition: rdmretcodetypes.h:58
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:43