cursor/printMembers.c
static RDM_RETCODE printMembers (RDM_CURSOR members)
{
RDM_CURSOR membersIter = NULL;
/* Clone members so we can leave its position as is */
rc = rdm_cursorGetClone (members, &membersIter);
if (rc == sOKAY || rc == sENDOFCURSOR)
{
rc = rdm_cursorMoveToFirst (membersIter);
}
while (rc == sOKAY)
{
RDM_TABLE_ID tableId;
rc = rdm_cursorGetTableId (membersIter, &tableId);
if (rc == sOKAY && tableId == TABLE_ADULT)
{
ADULT adult;
rc = rdm_cursorReadRow (membersIter, &adult, sizeof (ADULT), NULL);
if (rc == sOKAY)
{
printf (
"Adult with id: %d and name: %s\n", adult.adult_id,
adult.adult_name);
rc = rdm_cursorMoveToNext (membersIter);
}
}
else if (rc == sOKAY && tableId == TABLE_CHILD)
{
CHILD child;
rc = rdm_cursorReadRow (membersIter, &child, sizeof (CHILD), NULL);
if (rc == sOKAY)
{
printf (
"Child with id: %d and name: %s\n", child.child_id,
child.child_name);
rc = rdm_cursorMoveToNext (membersIter);
}
}
else if (rc == sOKAY)
{
printf ("Unknow member type, must be a secret member\n");
rc = rdm_cursorMoveToNext (membersIter);
}
}
if (rc == sENDOFCURSOR)
rc = sOKAY;
rdm_cursorFree (membersIter);
return rc;
}
RDM_RETCODE rdm_cursorMoveToFirst(RDM_CURSOR cursor)
Position a cursor to the first row in the collection.
RDM_RETCODE rdm_cursorGetTableId(RDM_CURSOR cursor, RDM_TABLE_ID *tableId)
Get the table id for the current row of the cursor.
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.
uint32_t RDM_TABLE_ID
Definition: rdmtypes.h:27
@ sOKAY
Definition: rdmretcodetypes.h:97
RDM_RETCODE rdm_cursorFree(RDM_CURSOR cursor)
Free an RDM_CURSOR.
RDM_RETCODE rdm_cursorGetClone(RDM_CURSOR sourceCursor, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR as a clone of an existing RDM_CURSOR.
@ sENDOFCURSOR
Definition: rdmretcodetypes.h:58
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:43