I'm trying to create a UDF which returns a table containing four values:
CREATE TABLE ts_table
(
  id character varying, 
  year integer, 
  rank double precision, 
  votes integer
);
Then, using a UDF, I have to return a table defined by (something along the lines of):
CREATE FUNCTION ts_myfunc(text) RETURNS SETOF ts_table AS $$
    'SELECT id,year,rank,votes FROM productions NATURAL JOIN directors NATURAL JOIN ratings WHERE attr is NULL AND pid=$1 ORDER BY year;'
$$ LANGUAGE SQL;
However, when I try to create the UDF with that command, I get
ERROR:  syntax error at or near "'SELECT id,year,rank,votes FROM productions NATURAL JOIN directors NATURAL JOIN ratings WHERE attr is NULL AND pid=$1 ORDER BY year;'"
LINE 2: 'SELECT id,year,rank,votes FROM productions NATURAL JOIN dir...