pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: La Chi <the_man.inmee@yahoo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: How to write cursors
Date: Tue, 3 Apr 2012 00:44:20 -0700 (PDT)
Message-ID: <1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com> (raw)

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

view thread (3+ messages)  latest in thread

Message-ID: <1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com>
Permalink:  ../1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com/
Also on:    postgresql.org/message-id/1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: the_man.inmee@yahoo.com
  Subject: Re: How to write cursors
  In-Reply-To: <1333439060.57914.YahooMailNeo@web162204.mail.bf1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox