Also see How to use UDFs if you have any problems with functions.