Re: [SQL] dynamic OUT parameters?

2009-02-01 Thread Pavel Stehule
Hello try to look on http://okbob.blogspot.com/2008/08/using-cursors-for-generating-cross.html regards Pavel Stehule 2009/2/1 Ivan Sergio Borgonovo : > On Sun, 01 Feb 2009 12:42:12 +0900 > Craig Ringer wrote: > >> gher...@fmed.uba.ar wrote: >> >> > Well, aparenty my problem remains, because th

Re: [SQL] dynamic OUT parameters?

2009-02-01 Thread Ivan Sergio Borgonovo
On Sun, 01 Feb 2009 12:42:12 +0900 Craig Ringer wrote: > gher...@fmed.uba.ar wrote: > > > Well, aparenty my problem remains, because the boss want that the > > programmers just need to call > > select * from report('table_name'). > > Then, AFAIK, you're not going to have much luck, as Pg needs

Re: [SQL] dynamic OUT parameters?

2009-01-31 Thread Craig Ringer
gher...@fmed.uba.ar wrote: > Well, aparenty my problem remains, because the boss want that the > programmers just need to call > select * from report('table_name'). Then, AFAIK, you're not going to have much luck, as Pg needs to know the columns that'll be output before the function is called. Ap

Re: [SQL] dynamic OUT parameters?

2009-01-31 Thread gherzig
> gher...@fmed.uba.ar wrote: > >> Oh, that looks promising. I wrongly supposed that RETURNING SETOF RECORD >> forces the use of OUT parameters. I will give your idea a try. > > Tom Lane's point about using a refcursor is (unsurprisingly) a good one. > If you return a refcursor from your function, y

Re: [SQL] dynamic OUT parameters?

2009-01-30 Thread Craig Ringer
gher...@fmed.uba.ar wrote: > Oh, that looks promising. I wrongly supposed that RETURNING SETOF RECORD > forces the use of OUT parameters. I will give your idea a try. Tom Lane's point about using a refcursor is (unsurprisingly) a good one. If you return a refcursor from your function, you don't h

Re: [SQL] dynamic OUT parameters?

2009-01-30 Thread gherzig
> Gerardo Herzig wrote: > >> 1) There is a way to make a function returning "any amount of any type >> of arguments"? > > RETURNS SETOF RECORD > > The application must, however, know what columns will be output by the > function ahead of time and call it using an explicit column declaration > list.

Re: [SQL] dynamic OUT parameters?

2009-01-30 Thread Tom Lane
Craig Ringer writes: >> 2) Can i make a special type "on_the_fly" and returning setof "that_type"? > You're better off using SETOF RECORD, at least in my opinion. Another possibility is to return a cursor. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql

Re: [SQL] dynamic OUT parameters?

2009-01-30 Thread Craig Ringer
Gerardo Herzig wrote: > 1) There is a way to make a function returning "any amount of any type > of arguments"? RETURNS SETOF RECORD The application must, however, know what columns will be output by the function ahead of time and call it using an explicit column declaration list. For example, t

[SQL] dynamic OUT parameters?

2009-01-30 Thread Gerardo Herzig
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_cou