From: Richard Hurst <richard.hurst@kirklees.gov.uk>
To: pgsql-sql@postgresql.org
Subject: Returning A Varchar From A Function
Date: Thu, 12 Aug 2004 10:04:49 +0100
Message-ID: <s11b40cb.055@kirklees.gov.uk> (raw)
Hi
this has been puzzling me for a few days now
I have created a function that I want to use in a database to select a
value from a table based on the value passed in.
The table is fairly simple
CREATE TABLE public.feeder_next_status
(
status varchar NOT NULL,
previous_status varchar,
next_status varchar
) WITH OIDS;
The function is defined as
-- Function: public.spgetnextstatus(varchar)
-- DROP FUNCTION public.spgetnextstatus(varchar);
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;
However when i run the query
select spgetnextstatus('NEW')
in pgadmin
the dataoutput shows two columns
the row column shows a row number of '1' and the column header
spgetnextstatus(varchar) shows blank
I have tested the equivalent sql in the pgadmin query and it works
fine.
Hoping someone can point me inthe right direction
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: richard.hurst@kirklees.gov.uk
Subject: Re: Returning A Varchar From A Function
In-Reply-To: <s11b40cb.055@kirklees.gov.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox