You might want to update or insert Database single statement rather than checking the record is inserted or and again go to the update. But using following SQL statement you can run First run and check Insert statement and if that fails Update statement after that.
This blog is about my Development Experiences