>>Hi everybody,
>>
>>Just wondering do you agree with the last statement or not in this thread
http://forums.asp.net/t/1368290.aspx ? Does it make sense to do UPDATE first, then INSERT? Or do check first? Or would be no difference here?
>>
>>Thanks in advance.
>
>Nispters' quick solution sample 2 is the worst I have ever seen:) It is a solution w/o thinking. Do not use that one and you could use any way you want:)
>
>I prefer the method posted by the original poster ( update, rowcount = 0 then insert - even in native VFP this was the way I were using). I think it is better than checking for existence first, because:
>
>exits?
> yes - update (total operations 2, exists + update)
> no - insert (total operations 2, exists + insert)
>
>In the other way:
>Update
> ( rowcount is a return value ) = 0?
> no - done (total operations 1 Update)
> yes insert (total operations 2 Update/fail/insert)
>
>PS: However there is another problem that would make this useless and the best way would be to use separate update and insert. Consider you are updating but update fails because of another reason (such as timestamp is your update's part, someone else has changed in between). I don't imply if exists() here but maybe. I know it at client side if I am updating or inserting and be explicit.
>
>Cetin
Thanks, Cetin.
If it's not broken, fix it until it is.
My Blog