Jiri Nemec <konference(at)menea(dot)cz> writes:
> CREATE FUNCTION foo(int2)
> RETURNS TEXT
> AS 'DECLARE ret TEXT;
> begin
> SELECT INTO ret CAST(name AS text)
> FROM shop_goods
> WHERE id = $1;
> return ret;
> end;'
> language 'sql';
This is a plpgsql function, not a sql function --- you are selecting
the wrong language.
regards, tom lane