cursor/printAdultsInReverseSortedOrder.c
static RDM_RETCODE printAdultsInReverseSortedOrder (RDM_DB db)
{
RDM_CURSOR adults = NULL;
ADULT fAdult;
bool is_before_first;
rc = rdm_dbGetRowsByKey (db, KEY_ADULT_ADULT_NAME, &adults);
if (rc == sOKAY)
{
rc = rdm_cursorMoveToLast (adults);
}
rc = rdm_cursorIsBeforeFirst (adults, &is_before_first);
while (rc == sOKAY && is_before_first == false)
{
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_cursorMoveToPrevious (adults);
}
if (rc == sENDOFCURSOR)
rc = sOKAY;
if (rc == sOKAY)
{
rc = rdm_cursorIsBeforeFirst (adults, &is_before_first);
}
}
rdm_cursorFree (adults);
return rc;
}
@ 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.
RDM_RETCODE rdm_cursorIsBeforeFirst(RDM_CURSOR cursor, bool *isBeforeFirst)
Check to see if a cursor is positioned before the first row in a collection.
RDM_RETCODE rdm_dbGetRowsByKey(RDM_DB db, RDM_KEY_ID keyId, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set based on a key.
@ 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_cursorMoveToLast(RDM_CURSOR cursor)
Position a cursor to the last row in the collection.
struct RDM_DB_S * RDM_DB
Definition: rdmtypes.h:346