Is it a good practice to rely on error code 1062 from application code, to make decisions, while inserting in key columns?
If you're asking whether the error code 1062 (duplicate key) is okay to rely on, yes. It will never change.