pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
help..postgresql mulyiple return values
2+ messages / 2 participants
[nested] [flat]

* help..postgresql mulyiple return values
@ 2006-05-12 10:38 Michael Joseph Tan <josephtan2k@yahoo.com>
  2006-05-18 17:53 ` Re: help..postgresql mulyiple return values Tony Wasson <ajwasson@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Michael Joseph Tan @ 2006-05-12 10:38 UTC (permalink / raw)
  To: pgsql-sql

hi,
  im new in postgresql, generally new in databases.
   
  im trying to make a function using PGAdminIII which returns several types, 
  example, my query is:
   
  "select count(id) as requests, organization from connection_requests group by organization"
   
  id is of type int8, organization is of type varchar(50).
   
  basically the query would return coun(id), and a varchar(50) which is organization.
   
  i really dont know what to put on the return type.
   
  what would be the best solution?
   
  hope to hear from you guys asap..
   
  thank you

		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: help..postgresql mulyiple return values
  2006-05-12 10:38 help..postgresql mulyiple return values Michael Joseph Tan <josephtan2k@yahoo.com>
@ 2006-05-18 17:53 ` Tony Wasson <ajwasson@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tony Wasson @ 2006-05-18 17:53 UTC (permalink / raw)
  To: Michael Joseph Tan <josephtan2k@yahoo.com>; +Cc: pgsql-sql

On 5/12/06, Michael Joseph Tan <josephtan2k@yahoo.com> wrote:
>
> hi,
> im new in postgresql, generally new in databases.
>
> im trying to make a function using PGAdminIII which returns several types,
> example, my query is:
>
> "select count(id) as requests, organization from connection_requests group
> by organization"
>
> id is of type int8, organization is of type varchar(50).
>
> basically the query would return coun(id), and a varchar(50) which is
> organization.
>
> i really dont know what to put on the return type.
>
> what would be the best solution?


If you are in 8.1 you can follow this example from the documentation.
http://www.postgresql.org/docs/8.1/interactive/plpgsql-declarations.html

CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$
BEGIN
    sum := x + y;
    prod := x * y;
END;
$$ LANGUAGE plpgsql;

Then run it like:

SELECT sum, prod FROM sum_n_product(1,2);



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-05-18 17:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-12 10:38 help..postgresql mulyiple return values Michael Joseph Tan <josephtan2k@yahoo.com>
2006-05-18 17:53 ` Tony Wasson <ajwasson@gmail.com>

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