X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 3195BD1B56B for ; Sat, 30 Aug 2003 21:00:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 59081-08 for ; Sat, 30 Aug 2003 17:59:45 -0300 (ADT) Received: from megazone.bigpanda.com (45.mufb.snfc.sffca01r18.dsl.att.net [12.103.249.45]) by svr1.postgresql.org (Postfix) with ESMTP id DCDCBD1B561 for ; Sat, 30 Aug 2003 17:59:38 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 4B4D1D65D; Sat, 30 Aug 2003 13:59:40 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 40E685C02; Sat, 30 Aug 2003 13:59:40 -0700 (PDT) Date: Sat, 30 Aug 2003 13:59:40 -0700 (PDT) From: Stephan Szabo To: Dan Langille Cc: Subject: Re: Getting the return type right for SETOF In-Reply-To: <3F50D3EF.27516.2FEF6552@localhost> Message-ID: <20030830135853.I74114-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/359 X-Sequence-Number: 14975 On Sat, 30 Aug 2003, Dan Langille wrote: > Hi folks, > > I'm playing with SETOF on functions. But I can't get the return type > correct. What have I missed? A cast? > > CREATE OR REPLACE FUNCTION elementGet (text) RETURNS SETOF > element_type AS ' > > select 1, > \'test\', > \'F\' > \'A\', > FALSE, > FALSE > ' > LANGUAGE sql stable; > ERROR: function declared to return element_type returns "unknown" > instead of text at column 2 I think you'll need to explicitly make the three text columns text rather than just a plain literal (so ''test''::text for example)