pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Svenne Krap <svenne@krap.dk>
To: pgsql-sql@postgresql.org
Subject: How to call table returning function with other table
Date: Sun, 19 Mar 2006 14:26:44 +0100
Message-ID: <441D5C14.8010204@krap.dk> (raw)

Hi.

I have a function that is defined like (which works, sorry for the 
pseudocode)
create type xxx as (id,...);
create function calcuate_xxx (integer) returns xxx as $$ select $1, 
(select sum(amount) from bigtable where something) as a, (select 
sum(amount) from bigtable where some-other-thing) as b $$ language sql 
stable;

What I cannot figure out is, if I have another query that returns a 
single column of those id's, how do I get a table back with the function 
applied to all ids (hence multiple rows).

So it is something like "select xxx(id) from othertable where otherwhere 
= 't'" except that it mangles the columns into an array. I have tried to 
move the function-call into the fromlist (as it is usually done) but I 
seem unsuccessful in getting the ID's into it.

Thanks in advance

Svenne

Attachments:

  smime.p7s (application/x-pkcs7-signature, 3.2K) download

view thread (3+ messages)  latest in thread

Message-ID: <441D5C14.8010204@krap.dk>
Permalink:  ../441D5C14.8010204@krap.dk/
Also on:    postgresql.org/message-id/441D5C14.8010204@krap.dk

 · 

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: svenne@krap.dk
  Subject: Re: How to call table returning function with other table
  In-Reply-To: <441D5C14.8010204@krap.dk>

* 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