X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6F45914B28C0 for ; Thu, 12 Aug 2004 06:05:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29515-01 for ; Thu, 12 Aug 2004 09:05:03 +0000 (GMT) Received: from webshielde500.kirklees.gov.uk (unknown [62.254.173.5]) by svr1.postgresql.org (Postfix) with SMTP id 8B2FA14B27FF for ; Thu, 12 Aug 2004 06:04:58 -0300 (ADT) Received: from unknown(10.0.2.12) by webshielde500.kirklees.gov.uk via csmap id c5fde65a_ec3e_11d8_8255_003048245ce8_7973; Thu, 12 Aug 2004 10:05:36 +0100 (BST) Received: from KMC Primary Domain-MTA by kirklees.gov.uk with Novell_GroupWise; Thu, 12 Aug 2004 10:04:59 +0100 Message-Id: X-Mailer: Novell GroupWise Internet Agent 6.5.1 Date: Thu, 12 Aug 2004 10:04:49 +0100 From: "Richard Hurst" To: Subject: Returning A Varchar From A Function Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/127 X-Sequence-Number: 18624 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