"Richard Hurst" <richard.hurst@kirklees.gov.uk> writes:
> CREATE OR REPLACE FUNCTION public.spgetnextstatus(varchar)
> RETURNS varchar AS
> '
> select cast(next_status as varchar)
> from feeder_next_status
> where trim(status) = trim(\'$1\')
> order by next_status;'
> LANGUAGE 'sql' STABLE;
Try it without the quotes:
where trim(status) = trim($1)
As is, the function is probably returning NULL because there are
no rows matching the literal value "$1".
regards, tom lane