Added function to create query dynamically considering the number of
parameters.