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.
@ 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
uint32_t RDM_TABLE_ID
Definition: rdmtypes.h:27
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_cursorGetClone(RDM_CURSOR sourceCursor, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR as a clone of an existing RDM_CURSOR.