SQL function

I'm re-using a sql expression that generates html to make a field "hot" with the "Mailto" link, and would like to store it as a function that can be called with arguments. If FB sql supports this, pls send me a pointer.