Recently, I've got a inclination to validate my saved procedure action query arguments before really carrying out the query. A good example is always to make sure that, on update to table 'T' which has a column 'C' with a unique index, the Update wouldn't fail... beginning with carrying out a "Choose Is available around the unique index" kind of query prior to the actual Update. When the unique index could be violated I'm therefore trapping the mistake early and coming back.

I've essentially built on my small usual positive securing means of analyzing the record I'm upgrading continues to be qualified for update i.e. has not transformed. I've taken it one step further by testing the unique index wouldn't be violated basically would carry out the Update.

The truth is, I have only lately began carrying this out and that i can't determine if it is the right factor to complete or I ought to just allow the Update handle the initial index failure.

Does anybody have seem advice in this region?

I am also thinking about other individuals methods to parameter validation generally.

It appears like lots of unnecessary work with me.

Also, presuming you are just altering the return value, you are taking an amount normally be the best and making it a saved method that returns another value. This can lead to logic errors, that are harder to trace.


Another thought I'd about this is you might be catching errors in the DB level that needs to be caught (or at best might be caught more beautifully) in the Business Logic or UI level.