Reputation: 26919
I want to update or insert a row in a table. I have also created an index on the column I am searching for in the WHERE clause.
The thing I want to insert into the table may or may not already exist in the table so it may be an update or an insert. So first I define a Boolean variable like "already_exists" and a select statement that goes and searches for the value in the table, if it finds it it will set the Boolean variable to true, else it will remain false. Then I say oh OK if that variable is true, then run this update command on the table, if it is false run this insert command.
So is it the right way of doing it or there are better ways?
Upvotes: 1
Views: 79