Re: how to write cursors

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: La Chi <the_man(dot)inmee(at)yahoo(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how to write cursors
Date: 2012-04-04 07:36:19
Message-ID: CAFj8pRCEe9CxX6P0Zg+JHCti6u7in2VO-BSogTJt5T1ucZxq0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

use a refcursors

http://www.postgresql.org/docs/9.1/static/plpgsql-cursors.html

Regards

Pavel Stehule

2012/4/4 La Chi <the_man(dot)inmee(at)yahoo(dot)com>:
> hi every one
>
> i have created this simple function which returns a column of table , i have
> used simple SELECT statement , i simply want to know how can i achieve the
> same task with the help of cursor
>
> CREATE OR REPLACE FUNCTION foo(id int)
> returns table(cust_id int) as
> $BODY$
>
> BEGIN
>
> return query Select userid from customer where proname ='shampoo';
> END;
> $BODY$
> LANGUAGE plpgsql;
>
> how can i write a cursor which should return all the custid who had proname
> shampoo . i shall be very thankful to you
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Julien Cigar 2012-04-05 11:38:38 bad plan
Previous Message La Chi 2012-04-04 07:30:28 how to write cursors