Re: Returning a varchar from a functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Richard Hurst" <richard(dot)hurst(at)kirklees(dot)gov(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Returning a varchar from a functions
Date: 2004-08-15 18:33:06
Message-ID: 28527.1092594786@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Richard Hurst" <richard(dot)hurst(at)kirklees(dot)gov(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-08-15 18:39:56 Re: boolean function return values
Previous Message Frank van Vugt 2004-08-15 18:12:34 (libpq) listen/notify messages are converted to lowercase and/or are case insensitive