hi!!
I am writing sql stored procedures and am stuck on this design issue as
follows
I have a procedure named InsertIntoTbl for doing inserts.
However i need to do 2 validation steps before i can do the insert
1 step 1 check if record already exists
2 step 2 some other validation using another table
Now my question is
1)Should i club these 2 validations in my InsertIntoTbl procedure as in :-
if step1 and step2 succeed
then do insert
else
return with error
2)or should i let InsertTbl just do the insert and write the 2 validations
as 2 seperate functions which i will call from my asp.net page
Pros of this approach:
the validations are business logic
if i need to add another validation i dont have to change my insertIntoTbl
procedure
Cons:
my insert proceudre is vulnerable since it doesnt do validations.If anyone
executes it without calling the 2 validation functions,records inserted will
be inconsistent.
So please tell me your views regarding this and the best design approach to
this problem
Thanks for your help.
cooltech