check unique code against database