| From: | La Chi <the_man(dot)inmee(at)yahoo(dot)com> |
|---|---|
| To: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
| Subject: | How to write cursors |
| Date: | 2012-04-03 07:44:20 |
| Message-ID: | 1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Hello everyone,
i have created this function in which i simply want to display a column values through a cursor , but unfortunately i am not getting the column values , this function is showing me simple column name but not the fields in column.
CREATE OR REPLACE FUNCTION foo(id int) returns table(user_id int) as
$BODY$
DECLARE r int;
DECLARE rs cursor for Select userid from customer where area ='new_york';
BEGIN
open rs ;
fetch next from rs into r;
while (found) loop
fetch Next from rs into r;
END loop;
close rs;
END;
$BODY$
LANGUAGE plpgsql;
i simply want to show all the record from customer table where area is New York but with the help of cursors.
thanks
| From | Date | Subject | |
|---|---|---|---|
| Next Message | La Chi | 2012-04-03 09:23:24 | Cursor Error |
| Previous Message | Gary Stainburn | 2012-04-02 09:11:31 | Re: Wrong output from union |