modified SQL function to take variable type of arguments