pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rehan Saleem <pk_rehan@yahoo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: How to Return Table From Function
Date: Sun, 22 Jan 2012 05:09:55 -0800 (PST)
Message-ID: <1327237795.19340.YahooMailNeo@web121606.mail.ne1.yahoo.com> (raw)

hi , i have created this function 


CREATE OR REPLACE FUNCTION totaloverlapcount(user_id integer , bg integer ,center_distance integer)
RETURNS varchar AS $$

DECLARE percentage record;
BEGIN



select fname, lname, count(userid) totalcount ,100.00*count(useriddetails)/totaluser into percentage
from users
where userid= user_id and bloodgroup>=bg and
(centredistance<=center_distance or center_distance=1)
group by fname, lname, user_id;
return percentage;


its just a dummy function , but all i want to know that how can i return fname , lname totalcount and percentage from this function in the form of table , not the return type varchar.
thanks

view thread (3+ messages)  latest in thread

Message-ID: <1327237795.19340.YahooMailNeo@web121606.mail.ne1.yahoo.com>
Permalink:  ../1327237795.19340.YahooMailNeo@web121606.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1327237795.19340.YahooMailNeo@web121606.mail.ne1.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: pk_rehan@yahoo.com
  Subject: Re: How to Return Table From Function
  In-Reply-To: <1327237795.19340.YahooMailNeo@web121606.mail.ne1.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