Returning a varchar from a functions

From: "Richard Hurst" <richard(dot)hurst(at)kirklees(dot)gov(dot)uk>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Returning a varchar from a functions
Date: 2004-08-11 07:18:28
Message-ID: s119d65b.099@kirklees.gov.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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
REATE 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Uwe C. Schroeder 2004-08-11 07:31:24 Slony setup help needed
Previous Message Shanmugasundaram Doraisamy 2004-08-11 07:02:53 How to identify which query is running - reg.