Groups | Blog | Home
all groups > sql server programming > july 2004 >

sql server programming : Business Rules



Eddie Pazz
7/25/2004 11:23:16 PM
I have some business rules that I need to enforce before committing data.
Normally I do this in my business objects. The analyst wants to implement
the rules through sprocs. I have created a sproc for insert and one for
update. My problem is that some rules apply when inserting and when
updating, thus I would need to duplicate them in both sprocs. Should I
create a third sproc that the other two would call to verify? Is this the
correct way?

bojci
7/26/2004 8:38:56 AM
Hi,

I think putting the common rules into a 3rd sp it's a good idea in this
case. Duplicating the same code can be a source of a lot of problems and
maybe hard to keep them in sync.


[quoted text, click to view]

Hari Prasad
7/26/2004 12:01:51 PM
Hi,

Create a INERT,UPDATE Trigger

Create trigger tri_ins_upd for Insert, Update for <table>
as
......
......Business rules
........


Thanks
Hari
MCDBA

[quoted text, click to view]

jeff.nospam NO[at]SPAM zina.com
7/26/2004 3:29:55 PM
On Sun, 25 Jul 2004 23:23:16 -0700, "Eddie Pazz" <drpazz@hotmail.com>
[quoted text, click to view]

Good questions. And you can argue both ways. The shared proc method
means you can update business logic once and have both updated. But
the shared business logic may be so minimal that the effort isn't
worth it, especially if other non-shared code has to be updated
anyway. You might consider a trigger, but that depends on what your
business logic is as to whether it makes sense. Creating a User
Defined Function may also be a better choice.

Eddie Pazz
7/27/2004 7:10:47 AM
I thought about doing this but got stumped on items where a stored procedure
works with multiple tables... when I enter a contact, the sprocs update the
contact, address, e-mail, and telephone tables all at once. If I use
triggers, I would have to create a trigger in all this tables to verify the
address, make sure e-mail is valid, etc. Wouldn't this affect performance?
That's the equivalent of 3 or more sprocs running for one insert.

[quoted text, click to view]

AddThis Social Bookmark Button