Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id A7A8B2E0046 for ; Mon, 7 Apr 2008 10:19:07 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 95673-06 for ; Mon, 7 Apr 2008 10:19:04 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by developer.postgresql.org (Postfix) with ESMTP id C736B2E0041 for ; Mon, 7 Apr 2008 10:19:04 -0300 (ADT) Received: from [157.92.155.58] (mailbis [157.92.155.58]) by mail.fmed.uba.ar (Postfix) with ESMTP id A6C98154221; Mon, 7 Apr 2008 10:19:04 -0300 (ART) Message-ID: <47FA1BDF.8050407@fmed.uba.ar> Date: Mon, 07 Apr 2008 10:04:31 -0300 From: Gerardo Herzig User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Anoop G CC: pgsql-sql@postgresql.org Subject: Re: how to returns set of records in PL/python References: <1a027d210804070547w3117f195qa279b487b896674d@mail.gmail.com> In-Reply-To: <1a027d210804070547w3117f195qa279b487b896674d@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/42 X-Sequence-Number: 30581 Anoop G wrote: >Hi , > > Iam new to plpython,how can I return a recordset from a plpython >function? > > Is there is any way give me an example; > > >plpgsql function >-------------------------------- > >CREATE OR REPLACE FUNCTION function_to_get_all_countries() RETURNS SETOF >RECORD AS $BODY$ >DECLARE > > r RECORD; > >BEGIN > > FOR r IN SELECT pk_bint_country_id,vchr_country FROM tbl_country LOOP > RETURN NEXT r; > END LOOP; > RETURN; > >END >$BODY$ LANGUAGE 'plpgsql'; > > > > >How i can get the same result using plpythonu and how I can call the >function (is there any user defined type required like in plpgsql)? > >Thanks in advance > >Anoop > > > Forgot to mention that postgres home page has some info about plpython. http://www.postgresql.org/docs/8.3/static/plpython-funcs.html Cya. Gerardo