Prevent failure in case no record is found (empty database) (fixes #1363)