Added SQL function definition