Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> writes:
> ... However, I cannot find the
> syntax to create a function in SQL. Specifically, how you return the result.
See
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xfunc.html#XFUNC-SQL
regards, tom lane