Splitting strored proc into series of database operations for compute_fields_job