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 914475E46C0 for ; Mon, 16 Aug 2004 09:49:41 -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 71380-07 for ; Mon, 16 Aug 2004 12:49:37 +0000 (GMT) Received: from pd7mo2no.prod.shaw.ca (idcmail-mo2no.cg.shawcable.net [64.59.134.9]) by svr1.postgresql.org (Postfix) with ESMTP id 2ECD55E37D0 for ; Mon, 16 Aug 2004 09:49:35 -0300 (ADT) Received: from pd8mr8no.prod.shaw.ca (pd8mr8no-qfe2.prod.shaw.ca [10.0.144.229]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with ESMTP id <0I2J0058EHUSDL@l-daemon> for pgsql-sql@postgresql.org; Mon, 16 Aug 2004 06:40:04 -0600 (MDT) Received: from pn7ml2no.prod.shaw.ca ([10.0.149.111]) by pd8mr8no.prod.shaw.ca (Sun ONE Messaging Server 6.0 HotFix 1.01 (built Mar 15 2004)) with ESMTP id <0I2J00KEBHUSRBD0@pd8mr8no.prod.shaw.ca> for pgsql-sql@postgresql.org; Mon, 16 Aug 2004 06:40:04 -0600 (MDT) Received: from Dell4500 (S01060004236fc1f7.wp.shawcable.net [24.77.13.13]) by l-daemon (iPlanet Messaging Server 5.2 HotFix 1.18 (built Jul 28 2003)) with SMTP id <0I2J0071DHUPKG@l-daemon> for pgsql-sql@postgresql.org; Mon, 16 Aug 2004 06:40:04 -0600 (MDT) Date: Mon, 16 Aug 2004 07:40:04 -0500 From: George Weaver Subject: Re: Returning A Varchar From A Function To: Richard Hurst , pgsql-sql@postgresql.org Message-id: <004101c4838e$29348900$6400a8c0@Dell4500> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Mailer: Microsoft Outlook Express 6.00.2800.1437 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=FAKE_HELO_SHAW_CA X-Spam-Level: X-Archive-Number: 200408/144 X-Sequence-Number: 18641 Hi Richard, What happens if you just do: where trim(status) = trim($1) Regards, George ----- Original Message ----- From: "Richard Hurst" To: Sent: Thursday, August 12, 2004 4:04 AM Subject: [SQL] Returning A Varchar From A Function > 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 > > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >