dynamic OUT parameters?

From: Gerardo Herzig <gherzig(at)fmed(dot)uba(dot)ar>
To: pgsql-sql(at)postgresql(dot)org
Subject: dynamic OUT parameters?
Date: 2009-01-30 11:01:24
Message-ID: 4982DE04.3080206@fmed.uba.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all. I have a situation here: I have to make a 'report' for a table.
I'll try to explain the functionality needed:
Lets say i have a table like this
\d people
name varchar
id_city integer (references city(id_city))

\d city
id_city integer
city_name varchar
id_country (references country (id_country))

\d country
id_country integer
country_name varchar

So, if i call report('people') i should return
name |city |country
Philip |Portland |UEA
Manuel |Madrid |España

And so on. This is: "Do *not* include those fields who are FK, instead,
put the referenced keyword from the referenced table".
It is not hard to do this in a query. Is not neither hard to make it a
function. But i have many tables to 'report', and the application leader
does not want querys in the program, just procedures call. So i would
like to have a generic function who should have the logic of 'selecting
the columns to show'. And then i have to ask:

1) There is a way to make a function returning "any amount of any type
of arguments"?

2) Can i make a special type "on_the_fly" and returning setof "that_type"?

3) Should (and/or can) i make a view "on_the_fly" and return from
"that_view"?

Comments awaiting. I hope the explanation is clear enough.
Thanks!
Gerardo

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gregory Stark 2009-01-30 11:14:53 Re: regexp_replace and UTF8
Previous Message Bart Degryse 2009-01-30 10:26:48 regexp_replace and UTF8