SQL * Insert(CATEGORIES)
(CAT_ID, some_value);
SQL * Update(CATEGORIES)(CAT_ID, update_value).Where(ID == key);
Sql sql;
sql * Select(ID, CAT_ID).From(CATEGORIES).Where(... some condition ...);
now the loop can look like
int id, cat_id;
while(sql.Fetch(id, cat_id)) ...
or
while(sql.Fetch()) { .. sql[ID] .. sql[0] .. }
(you can use either ids or indexes).
Alternatively, you can use S_CATEGORIES structure to work with the whole record.