Re: Returning a varchar from a functions - Mailing list pgsql-general

From Tom Lane
Subject Re: Returning a varchar from a functions
Date
Msg-id 28527.1092594786@sss.pgh.pa.us
Whole thread Raw
In response to Returning a varchar from a functions  ("Richard Hurst" <richard.hurst@kirklees.gov.uk>)
List pgsql-general
"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

pgsql-general by date:

Previous
From: s post
Date:
Subject: notes on SERIALIZABLE transactions
Next
From: Tom Lane
Date:
Subject: Re: boolean function return values