Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id CED334BB8E6 for ; Wed, 4 Apr 2012 04:30:46 -0300 (ADT) Received: from nm17-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.157]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SFKfy-0003Dm-Lv for pgsql-sql@postgresql.org; Wed, 04 Apr 2012 07:30:45 +0000 Received: from [98.139.212.153] by nm17.bullet.mail.bf1.yahoo.com with NNFMP; 04 Apr 2012 07:30:29 -0000 Received: from [98.139.212.237] by tm10.bullet.mail.bf1.yahoo.com with NNFMP; 04 Apr 2012 07:30:29 -0000 Received: from [127.0.0.1] by omp1046.mail.bf1.yahoo.com with NNFMP; 04 Apr 2012 07:30:29 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 77367.45688.bm@omp1046.mail.bf1.yahoo.com Received: (qmail 43239 invoked by uid 60001); 4 Apr 2012 07:30:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1333524629; bh=ZX0iSdjeTGYJfBiooACBG6irqtE3VDLTNc2rf66sAPg=; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=uj9MHqEDFWkb6Nm95hukkrDP9ZGmfwbbd7LskMNT8XttNe5eSfKV1tFMgvAb+hsy5OdjDeZWkDTdGvdRMCCdASGIYDD2CzGM3BF2sCqQWaZwYLaE4tCIpKLSKfclOaP49ZZbG2LYmNaZ13LePRLy8iGBXy8Srmi3ZPfsfRrU8VE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Message-ID:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=Z/gkK+P2KCrK6NlWssrRCDTE2XHcocbrTxgeBryaf7lPPSafjpqc8KvxCxSPl/2D4x7c090i74Lg8zSzUq4hIPYbAXaSxfMVGxH9Y9woqeqkO+jOk4R0V0x4+LZNAyF3Klfc8k5zRTrtWX/DzfnFvZCfeKZqaAOtqvciq3Iok1c=; X-YMail-OSG: kSmCJdYVM1l3iGOEvQM5J_QrVal1hU6O7D3A7MmWIXfE2Tx KG6RszMfGe8BaVmwbT3QzpR.vzSIdRqAvbxW9mNfZ3lVpYPq5jVxBWagusjQ 6ysiKPEtgvowTTb8_j00BB0wa6NlZCYGhWJ0lLKQoOh_mcRy5m_Dwb.yC8nq X7nK56cuYBkWqsw6KAeshnkDqJqAPiQ4phsSIFhFufQ7c5QKAjLqgrqVNePp EtXu4WBx_KM1iIRZtBOhAr5OIAR8AbV4Mq6ERG.b7mmp9iMe.mVb6FstZkPT Z_WcK0UnnFVRnJgNn1qzgBkk8URqevwQ0RGIw8sFJfSWdFepIgcZqAPjCf_y 1zJDY_SyUOb5ZX5q6nbugiz1wtKRx5WA.7AmWSwmFUP_GKlZIDeE8vsJkI1U 5AMgK5LZumyPZazOisagekSvd0ytM6Q-- Received: from [182.177.203.249] by web162203.mail.bf1.yahoo.com via HTTP; Wed, 04 Apr 2012 00:30:28 PDT X-Mailer: YahooMailWebService/0.8.117.340979 Message-ID: <1333524628.40393.YahooMailNeo@web162203.mail.bf1.yahoo.com> Date: Wed, 4 Apr 2012 00:30:28 -0700 (PDT) From: La Chi Reply-To: La Chi Subject: how to write cursors To: "pgsql-sql@postgresql.org" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="900607865-617215373-1333524628=:40393" X-Pg-Spam-Score: 1.6 (+) X-Archive-Number: 201204/7 X-Sequence-Number: 36484 --900607865-617215373-1333524628=:40393 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable hi every one=0A=0Ai have created this simple function which returns a colum= n of table , i have used simple SELECT statement , i simply want to know ho= w can i=A0achieve=A0the same task with the help of cursor=0A=0ACREATE OR RE= PLACE FUNCTION foo(id int)=0Areturns table(cust_id int) as=0A$BODY$=0A=0ABE= GIN=0A=A0 =A0 =A0 =A0=0Areturn query Select userid from customer where pron= ame =3D'shampoo';=0AEND;=0A$BODY$=0ALANGUAGE plpgsql;=0A=0Ahow can i write = a cursor which should return all the custid who had proname shampoo . i sha= ll be very thankful to you=A0=0A --900607865-617215373-1333524628=:40393 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
hi ev= ery one

i have created this simple function = which returns a column of table , i have used simple SELECT statement , i s= imply want to know how can i achieve the same task with the help of curs= or

CREATE OR REPLACE FUNCTION foo(id int)
returns table(cust_id int) as
$BODY$
BEGIN= =09
       
=09=09return query Select u= serid from customer where proname =3D'shampoo';
=09=09
END;
<= div>$BODY$
LANGUAGE plpgsql;

how can i w= rite a cursor which should return all the custid who had proname shampoo . = i shall be very thankful to you 

--900607865-617215373-1333524628=:40393--