all groups > sql server programming > december 2006 >
You're in the

sql server programming

group:

How to handle insert/update sprocs with common business logic?


How to handle insert/update sprocs with common business logic? Tadwick
12/7/2006 11:57:00 PM
sql server programming:
Is it best to keep all insert and update statements in separate sprocs even
if they share common business logic for validation/calculation etc? Is it
possible and/or even preferable to create a single sproc for the business
logic and call it from the separate insert and update sprocs? Does this
affect how error messages are raised and transactions are handled?

Re: How to handle insert/update sprocs with common business logic? Dan Guzman
12/8/2006 5:39:54 AM
If you choose to implement business rules in stored procedures, the obvious
advantage of the shared proc approach is that you don't have to replicate
code. It's usually best to keep validation procs simple and pass validation
codes/messages via output parameters. Keep transaction handling in the
calling proc or client.

This approach works well for single-row insert/updates but a downside is
that you can't easily perform set-based processing (e.g. insert from staging
table with validation/calculation).

--
Hope this helps.

Dan Guzman
SQL Server MVP

[quoted text, click to view]
Re: How to handle insert/update sprocs with common business logic? s
12/8/2006 6:37:57 AM
Thanks, Dan - I should have mentioned that this is for single row ops.
Thanks again for the advice.

Tad


[quoted text, click to view]

AddThis Social Bookmark Button