pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Fetching a single column from a record returning function
4+ messages / 3 participants
[nested] [flat]

* Fetching a single column from a record returning function
@ 2004-01-20 06:12  Kumar <sgnerd@yahoo.com.sg>
  0 siblings, 2 replies; 4+ messages in thread

From: Kumar @ 2004-01-20 06:12 UTC (permalink / raw)
  To: pgsql-sql

Hi Friends,

Postgres 7.3.4 on RH Linux 7.2

I am using a record variable inside a functions and fetch the result via the follow command

select * from .fn_email(1) 
as (email_folder_id int4,email_folder_name varchar,descrip varchar,msgcount int8,unreadcount int8,size int8);


Is it possible to fetch only one column (the 'msgcount') from the function. Because I am interested in SUM(msgcount).  Please shed some light.

Regards
kumar

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

* Re: Fetching a single column from a record returning function
@ 2004-01-20 15:58  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Kumar <sgnerd@yahoo.com.sg>
  1 sibling, 1 reply; 4+ messages in thread

From: Tom Lane @ 2004-01-20 15:58 UTC (permalink / raw)
  To: Kumar <sgnerd@yahoo.com.sg>; +Cc: pgsql-sql

"Kumar" <sgnerd@yahoo.com.sg> writes:
> select * from fn_email(1)
> as (email_folder_id int4,email_folder_name varchar,descrip varchar,msgcount
>  int8,unreadcount int8,size int8);

> Is it possible to fetch only one column (the 'msgcount') from the function.=
>  Because I am interested in SUM(msgcount).  Please shed some light.

select sum(msgcount) from fn_email(1)
as (email_folder_id int4,email_folder_name varchar,descrip varchar,msgcount
 int8,unreadcount int8,size int8);

			regards, tom lane



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

* Re: Fetching a single column from a record returning function
@ 2004-01-20 16:13  Joe Conway <mail@joeconway.com>
  parent: Kumar <sgnerd@yahoo.com.sg>
  1 sibling, 0 replies; 4+ messages in thread

From: Joe Conway @ 2004-01-20 16:13 UTC (permalink / raw)
  To: Kumar <sgnerd@yahoo.com.sg>; +Cc: pgsql-sql

Kumar wrote:
> select * from .fn_email(1) as (email_folder_id int4,email_folder_name
> varchar,descrip varchar,msgcount int8,unreadcount int8,size int8);
> 
> Is it possible to fetch only one column (the 'msgcount') from the
> function. Because I am interested in SUM(msgcount).  Please shed some
> light.


What's wrong with:

select msgcount from fn_email(1)
as (email_folder_id int4,email_folder_name varchar,descrip 
varchar,msgcount int8,unreadcount int8,size int8);

?

Try showing us more detail about what you want to do and why it isn't 
currently working.

Joe





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

* Re: Fetching a single column from a record returning function
@ 2004-01-21 06:29  Kumar <sgnerd@yahoo.com.sg>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Kumar @ 2004-01-21 06:29 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

Yes it worked. Thanks

----- Original Message ----- 
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Kumar" <sgnerd@yahoo.com.sg>
Cc: "psql" <pgsql-sql@postgresql.org>
Sent: Tuesday, January 20, 2004 9:28 PM
Subject: Re: [SQL] Fetching a single column from a record returning function


> "Kumar" <sgnerd@yahoo.com.sg> writes:
> > select * from fn_email(1)
> > as (email_folder_id int4,email_folder_name varchar,descrip
varchar,msgcount
> >  int8,unreadcount int8,size int8);
>
> > Is it possible to fetch only one column (the 'msgcount') from the
function.=
> >  Because I am interested in SUM(msgcount).  Please shed some light.
>
> select sum(msgcount) from fn_email(1)
> as (email_folder_id int4,email_folder_name varchar,descrip
varchar,msgcount
>  int8,unreadcount int8,size int8);
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings




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


end of thread, other threads:[~2004-01-21 06:29 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-20 06:12 Fetching a single column from a record returning function Kumar <sgnerd@yahoo.com.sg>
2004-01-20 15:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2004-01-21 06:29   ` Kumar <sgnerd@yahoo.com.sg>
2004-01-20 16:13 ` Joe Conway <mail@joeconway.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