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 36445D1B52C for ; Wed, 27 Aug 2003 12:11:50 -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 28151-09 for ; Wed, 27 Aug 2003 12:11:19 -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 8B117D1B8E3 for ; Wed, 27 Aug 2003 12:11:15 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 200D5D61A; Wed, 27 Aug 2003 08:11:13 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 0DAE25C0E; Wed, 27 Aug 2003 08:11:13 -0700 (PDT) Date: Wed, 27 Aug 2003 08:11:12 -0700 (PDT) From: Stephan Szabo To: Kumar Cc: psql Subject: Re: How to return a record set from function. In-Reply-To: <006901c36c6b$65ab2000$7502a8c0@hdsc.com> Message-ID: <20030827080844.D68510-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/325 X-Sequence-Number: 14941 On Wed, 27 Aug 2003, 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 ' Why not setof t1? > select c1, c2, c3 from t1; > ' Language SQL; > > It was fine and created a function. while i execute it as > > select sel_t1; You probably want select * from sel_t1() as tab(c1 int, c2 varchar, c3 varchar) (if you return setof record) or select * from sel_t1(); (if you return setof t1)