Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cr8nk
Yak Posting Veteran
77 Posts |
Posted - 2007-12-20 : 19:19:49
|
| Hello,What level of parameter validation is recommended in stored procedures? Right now I validate only data that doesn't have an associated constraint. I don't check input parameters that have constraints (foreign key, not null, check) against the database. I am letting the statement fail and returning the error number. Is there a recommended best practice for validating your inputs?thanks,Creighton |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2007-12-20 : 19:42:54
|
| that is a big topic. I'll ramble for a bit:Based on your question I assume you are referring to simple Insert and Update SPs. In that case, IMO, I let the database raise the errors (constraint violations, etc). However, the SP could have logic built in that may require additional validations ie: a set of parameters are mutually exclusive. I would enforce any of those types of constraints via validation. There may be cases where a business rule says that rather than throw a PK violation you would turn the insert into an update. In that case if you want to inform the user of that action you would need to "validate" the input. That may not be a good example because you could always assume it is an update then do the insert only of no rows were updated - but I think you get my meaning.Be One with the OptimizerTG |
 |
|
|
|
|
|