cursor/adoptChild.c
static RDM_RETCODE adoptChild (
uint32_t childId,
uint32_t newMotherId,
uint32_t newFatherId,
RDM_DB db)
{
RDM_RETCODE rc;
RDM_CURSOR child = NULL;
RDM_CURSOR newMother = NULL;
RDM_CURSOR newFather = NULL;
rc = rdm_dbGetRowsByKeyAtKey (
db, KEY_ADULT_ADULT_ID, &newMotherId, sizeof (newMotherId), &newMother);
{
rc = rdm_dbGetRowsByKeyAtKey (
db, KEY_ADULT_ADULT_ID, &newFatherId, sizeof (newFatherId),
&newFather);
}
if (rc == sOKAY)
{
rc = rdm_dbGetRowsByKeyAtKey (
db, KEY_CHILD_CHILD_ID, &childId, sizeof (childId), &child);
}
if (rc == sOKAY)
{
rc = rdm_cursorRelinkRow (child, REF_MOTHERS_CHILDREN, newMother);
}
if (rc == sOKAY)
{
rc = rdm_cursorRelinkRow (child, REF_FATHERS_CHILDREN, newFather);
}
rdm_cursorFree (child);
rdm_cursorFree (newMother);
rdm_cursorFree (newFather);
return rc;
}
RDM_RETCODE rdm_dbGetRowsByKeyAtKey(RDM_DB db, RDM_KEY_ID keyId, const void *keyValue, size_t len, RDM_CURSOR *pCursor)
Associate an RDM_CURSOR with a row set that is ordered by key value and is initially positioned at th...
RDM_RETCODE rdm_cursorRelinkRow(RDM_CURSOR cursor, RDM_REF_ID refId, RDM_CURSOR cursorOwner)
Unlink a row from one owner and link to another.