Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to handle many similar SPROCS
Message
From
08/01/2008 09:45:34
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
Databases
Title:
How to handle many similar SPROCS
Environment versions
Environment:
VB 8.0
Database:
MS SQL Server
Miscellaneous
Thread ID:
01280182
Message ID:
01280182
Views:
63
I need some advice...

In most of my applications, I find myself making many SPROCs that return the same data only with different criteria. For example, I will have a combination of the following: usp_SelectDealerByDealerID, usp_SelectActiveDealers, usp_SelectAllDealers, etc... These SPROCS return the same result set structure but different data.

I am tired of maintaining several SPROCs and think there has to be a better way of doing it.

Here is what I started doing: I created one usp_SelectDealer SPROC, and I am including several optional parameters and I can achieve my desired results using any combination of parameters. I create one function in my DAL to accept all parameters and retrieve the data, and I am having my BIZ layer contain functions like GetAllDealers, GetActiveDealers, etc. and be responsible for the parameters to supply. I think this is working well because I have a limited number of SPROCS, but I am worried I am going to build a monster that is hard to maintain.

Another idea I had was to have one general SPROC (usp_SelectDealers) that would accept a variable number of DealerID's and return those records. I would have to have another query that returned the dealer ID's of all active dealers (for example), and then provide those to the main SPROC.

How does everybody else deal with issues like these? Am I overthinking this?
Very fitting: http://xkcd.com/386/
Next
Reply
Map
View

Click here to load this message in the networking platform