Create FUNCTION postgresql return TABLE

The entire function definition that you provide to the CREATE FUNCTION must be a single quoted string.

It means that if the function has any single quote ('), you have to escape it.Fortunately, from version 8.0, PostgreSQL provides a feature called dollar quoting that allows you to choose a suitable string that does not appear in the function so that you don’t have to escape it. As Robert Treat pointed out in our PostgreSQL 8.3 is out and the Project Moves On, one of the features that was introduced in PostgreSQL 8.0 was the syntax of ALTER TABLE sometable ALTER COLUMN somecolumn TYPE new_data_type USING some_function_call_to_cast (somecolumn);