September 26, 2005 at 12:43 pm
I have a sp that looks for various values and does processing based on the value. I'm wondering if these values should instead be in a code/desc table.
The sp says:
If Not @status in ('xxx','bbbbbb','vvvvvvvvv','ttttt','mmmmmm','ccccc','zzzzzzz',
'wwwwww')
begin various processing
Should I instead create a code table that contains the possible status codes? What questions should I be asking to determine if these should be in a table instead of the sp?
September 26, 2005 at 12:47 pm
The real question is why are they not already in such a table??
September 26, 2005 at 12:55 pm
Well, that's real helpful. What I want to know is how to determine if a table is needed or not? I don't want to create another code table if it's not necessary, ie, there's only 7 codes and that amount is not expected to grow, it saves a trip to the db, only 2 procs would access the table...when does the overhead of another code table outweigh the hardcoding?
September 26, 2005 at 1:17 pm
There's the keyword... You shouldn't have hardcoding whenever possible. Imagine this app 3 years from now. You have coded that in 9-10 places and now you have to add one more code for whatever reason. You, or the next developper, now have to edit 10 procs and maybe the app too?.
Or you can do a simple insert into.
Unless this proc is ran 100 M times a day, I wouldn't bother about the fetching of 9 values in another table.
September 27, 2005 at 8:21 pm
Even if the proc is run 100 M times a day, using a code table is a good idea. Remember that the requirement that will never ever change, can change. Also, if the table is small, a few records or so, it can also be pinned into memory so calls to the table will occur in memory.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply