cursor/printANumberOfAdultsArroundRecordInSortedOrder.c
static RDM_RETCODE printANumberOfAdultsArroundRecordInSortedOrder (
RDM_CURSOR adult,
uint32_t num)
{
ADULT fAdult;
RDM_CURSOR adultsSorted = NULL;
uint32_t ii;
adult, KEY_ADULT_ADULT_NAME, &adultsSorted);
for (ii = 0; rc == sOKAY && ii < num / 2; ii++)
{
rc = rdm_cursorMoveToPrevious (adultsSorted);
}
if (rc == sENDOFCURSOR)
{
rc = rdm_cursorMoveToNext (adultsSorted);
}
for (ii = 0; rc == sOKAY && ii < num; ii++)
{
rc = rdm_cursorReadRow (adultsSorted, &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 (adultsSorted);
}
}
if (rc == sENDOFCURSOR)
rc = sOKAY;
rdm_cursorFree (adultsSorted);
return rc;
}
RDM_RETCODE rdm_cursorMoveToNext(RDM_CURSOR cursor)
Position a cursor to the next row in the collection.
@ sENDOFCURSOR
Definition: rdmretcodetypes.h:58
struct RDM_CURSOR_S * RDM_CURSOR
Definition: rdmtypes.h:347
RDM_RETCODE rdm_cursorReadRow(RDM_CURSOR cursor, void *colValues, size_t bytesIn, size_t *bytesOut)
Read all columns from a row.
@ sOKAY
Definition: rdmretcodetypes.h:100
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.
enum RDM_RETCODE_E RDM_RETCODE
RaimaDB status and error return codes.
RDM_RETCODE rdm_cursorGetRowsByKeyAtPosition(RDM_CURSOR sourceCursor, RDM_KEY_ID keyId, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set based on a key and positioned to the same row as the source cu...