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