Added check that record with specified primary key exists

Fixes bug 1213205

Change-Id: I1c8bc0557f8219a52e3e28ef0f78a5a8f26e3042