A query
I need to make an sp that receives three string parameters that are used to filter in the where
The doubt I have is that only one can come with data and the other two empty like the three with data
What had occurred to me is to make a string and concatenate depending on whether the variable it receives as a parameter is empty or not.
Is there any other way to do it?
For example if var1 = "test", var2 ="", var3 ="" In the where only var1 should go
On the other hand, if all three have data, all three should go. It may be the case that var2 has data and the other two do not, such as var3 having data and the others not or var2 and var3 having data
Thank you very much
Cheers
There will be many ways to do this. For now I suggest you make your dynamic query in a variable
varchar
, and then execute it viaexecute immediate
. (I suggest you investigate more aboutexecute immediate
and look for examples)