Thread: How to write cursors

How to write cursors

From
La Chi
Date:
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