X-Original-To: pgsql-sql@postgresql.org Received: from rtlocal.trade-india.com (mail-relay.trade-india.com [203.196.129.235]) by postgresql.org (Postfix) with SMTP id 6A13547590C for ; Sun, 9 Mar 2003 00:59:26 -0500 (EST) Received: (qmail 9010 invoked from network); 9 Mar 2003 05:59:03 -0000 Received: from unknown (HELO system67.trade-india-local.com) (192.168.0.67) by infocom-236-129-del.trade-india.com with SMTP; 9 Mar 2003 05:59:03 -0000 From: Rajesh Kumar Mallah Organization: Infocom Network Limited To: "jack" , Subject: Re: pl/pgsql how to return multiple values from a function Date: Sun, 9 Mar 2003 11:29:28 +0530 User-Agent: KMail/1.5 References: <002101c2e5fe$a76a2340$1400a8c0@jac> In-Reply-To: <002101c2e5fe$a76a2340$1400a8c0@jac> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200303091129.28939.mallah@trade-india.com> X-Archive-Number: 200303/220 X-Sequence-Number: 12260 http://techdocs.postgresql.org/guides/SetReturningFunctions On Sunday 09 March 2003 11:12 am, jack wrote: > I found following notes on news list with Google. And I have a try but it > still doesn't work. The problem is pl/pgsql complains that function of col1 > is not found. My postgres is v7.3.2. Please help. Thank you in advance. > > Jack > ------ > Sure you can, I wouldn't nessessarily recommend it. rec_tmp must be a > table somewhere so it can be a 'type', you get the values from the record > by using syntaxt like SELECT col1(teste_tmp(1)), col2(teste_tmp(1)), > col3(teste_tmp(1)); > > You could also return a CURSOR but I've never tried that (I access > PostgreSQL from perl's DBI which doesn't support a cursor return type). > > Joshua b. Jore ; http://www.greentechnologist.org ; 10012 11010 11022 > 10202 1012 2122 11020 10202 10202 11002 1020 1012 11102 11102 11102 1201 > 11001 11002 10211 11020 10202 10202 11002 11021 1201 11010 11020 10211 > > On Tue, 28 May 2002, Vilson farias wrote: > > > Greetings, > > > > I would like to know if it's possible to return a record from a pl-pgsql > > function. > > > > The procedure I did is bellow and of course doesn't work. Is there some > > possibility or work-around? > > > > CREATE FUNCTION teste_tmp(INT4) > > RETURNS RECORD AS ' > > DECLARE > > rec_tmp record; > > BEGIN > > SELECT > > INTO rec_tmp > > 1 as col1, ''teste'' as col2, now() as col3 ; > > > > RETURN rec_tmp; > > END; > > ' > > LANGUAGE 'plpgsql'; > > > > Best regards, > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > > -- Regds Mallah ---------------------------------------- Rajesh Kumar Mallah, Project Manager (Development) Infocom Network Limited, New Delhi phone: +91(11)6152172 (221) (L) ,9811255597 (M) Visit http://www.trade-india.com , India's Leading B2B eMarketplace.