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 DF3A4D1B550 for ; Wed, 27 Aug 2003 10:50:44 -0300 (ADT) 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 04819-02 for ; Wed, 27 Aug 2003 10:50:16 -0300 (ADT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 290F4D1B52C for ; Wed, 27 Aug 2003 10:50:12 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 19s0gh-0003Rg-0Y; Wed, 27 Aug 2003 14:50:15 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id B04EA163E4; Wed, 27 Aug 2003 14:50:13 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 0D220163D7; Wed, 27 Aug 2003 14:50:13 +0100 (BST) From: Richard Huxton To: "Kumar" , "psql" Subject: Re: How to return a record set from function. Date: Wed, 27 Aug 2003 14:50:12 +0100 User-Agent: KMail/1.5 References: <006901c36c6b$65ab2000$7502a8c0@hdsc.com> In-Reply-To: <006901c36c6b$65ab2000$7502a8c0@hdsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200308271450.12485.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/327 X-Sequence-Number: 14943 On Wednesday 27 August 2003 08:18, Kumar wrote: > Dear Friends, > > I am newbie to Postgres. I am running 7.3.4 on Linux 7.3. I am using > Pgadmin tool. I need to return the table rows via record set. > > Create table t1 (c1 int, c2 varchar, c3 varchar); > > Create or Replace function sel_t1 () returns setof records as ' > select c1, c2, c3 from t1; > ' Language SQL; > > It was fine and created a function. while i execute it as > > select sel_t1; > > I got the following error. > > ERROR: Cannot display a value of type RECORD You probably want to return "setof t1" and then do: SELECT * FROM sel_t1(); -- Richard Huxton Archonet Ltd