Format query when returning error from selectOneRow