merged_id is a bad name I think. It should be called linked_id. Please change the error msg to say the statement must not be "linked"