cursor/insertChildrenWithSiblings.c
static RDM_RETCODE insertChildrenWithSiblings (
RDM_CURSOR siblingsOnMothersSide,
RDM_CURSOR siblingsOnFathersSide,
const CHILD *children,
uint32_t nChildren,
RDM_DB db)
{
RDM_CURSOR inserted = NULL;
uint32_t ii;
for (ii = 0; rc == sOKAY && ii < nChildren; ii++)
{
printf (
"Insert children with id: %d and name: %s\n", children[ii].child_id,
children[ii].child_name);
rc = rdm_dbInsertRow (
db, TABLE_CHILD, &children[ii], sizeof (CHILD), &inserted);
printf ("Connect the newly created child to its parents\n");
if (rc == sOKAY && siblingsOnMothersSide)
{
rc = rdm_cursorAddMember (siblingsOnMothersSide, inserted);
}
if (rc == sOKAY && siblingsOnFathersSide)
{
rc = rdm_cursorAddMember (siblingsOnFathersSide, inserted);
}
}
rdm_cursorFree (inserted);
return rc;
}
RDM_RETCODE rdm_cursorAddMember(RDM_CURSOR setCursor, RDM_CURSOR memberCursor)
Add a row to a set cursor (link)
RDM_RETCODE rdm_dbInsertRow(RDM_DB db, RDM_TABLE_ID tableId, const void *colValues, size_t bytesIn, RDM_CURSOR *pCursor)
Insert a new row into a table at the specified rowId.