Define 8 parameters in a Object's function ~~

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I got a gobal object which has search function . I will pass 8 paramemter in
that object,
And In that search function, it will call 'stored procedure' with filling 8
parameters.
in that stored procedure, there is select case@ statment.

My question is, will the above design too BAD ??? or Should I changed the
design (not using the store procedure
with parameters, , BUT use commandtext (e.g select xx from myTable where
xxxxx) instead ??>

Thanks a lot.
 
Hi,

I wouldn't do it that way. In your stored procedure, where you declare your
inputs, set them all to NULL as default. Then only pass in the parameters
that you need, so if you pass in only two, say @FirstName and @LastName then
all the rest will be null. Then write your stored procedure like this:

Select
*
From
People
Where
((FirstName = @FirstName) OR (@FirstName IS NULL)) AND
((LastName = @LastName) OR (@LastName IS NULL)) AND
((Age = @Age) OR (Age IS NULL)) AND
 
Yeap, your point is great' Doing it this way you won't have to create a huge
web of conditionals to try
to generate a valid query. ' I will try your codes,
Thanks
 
Back
Top