rtree/deleteZipcode.c
static RDM_RETCODE deleteZipCode (RDM_DB db)
{
RDM_CURSOR cursor = NULL;
POINTSOFINTEREST_CITY_KEY keyVal = {{0}};
RDM_RANGE_KEY range = {0};
/* Set the key value for the lookup */
strcpy (keyVal.city, "Nampa");
/* Set key lookup information */
range.value = &keyVal;
range.bytesIn = sizeof (POINTSOFINTEREST_CITY_KEY);
range.numKeyCols = 1;
/* Start an update transaction */
rc = rdm_dbStartUpdate (db, RDM_LOCK_ALL, 0, NULL, 0, NULL);
if (rc == sOKAY)
{
/* Get a range cursor based on the city key */
db, KEY_POINTSOFINTEREST_CITY, &range, &range, &cursor);
if (rc == sOKAY)
{
/* Move to the first (should be only) row in the cursor */
rc = rdm_cursorMoveToFirst (cursor);
while (rc == sOKAY)
{
/* Delete the row */
rc = rdm_cursorDeleteRow (cursor);
if (rc == sOKAY)
{
rc = rdm_cursorMoveToNext (cursor);
}
}
/* We expect sENDOFCURSOR when we break out of the loop */
if (rc == sENDOFCURSOR)
{
rc = sOKAY;
}
/* Free the cursor */
(void) rdm_cursorFree (cursor);
}
if (rc == sOKAY)
{
/* Commit the successful transaction */
rc = rdm_dbEnd (db);
}
else
{
/* Rollback the failed transaction */
(void) rdm_dbEndRollback (db);
}
}
return rc;
}