cursor/insertChildren.c
static RDM_RETCODE insertChildren (
RDM_CURSOR mother,
RDM_CURSOR father,
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, name: %s, and nickname: %s\n",
children[ii].child_id, children[ii].child_name,
children[ii].child_nickname);
rc = rdm_dbInsertRow (
db, TABLE_CHILD, &children[ii], sizeof (CHILD), &inserted);
printf ("Connect the newly created child to its parents\n");
if (rc == sOKAY && mother)
{
rc = rdm_cursorLinkRow (inserted, REF_MOTHERS_CHILDREN, mother);
}
if (rc == sOKAY && father)
{
rc = rdm_cursorLinkRow (inserted, REF_FATHERS_CHILDREN, father);
}
}
rdm_cursorFree (inserted);
return rc;
}
RDM_RETCODE rdm_cursorLinkRow(RDM_CURSOR cursor, RDM_REF_ID refId, RDM_CURSOR cursorOwner)
Link a row to an owner.
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.