Improved parameter passing to SQL functions