Re: [GENERAL] plpgsql returning resultset

2008-09-03 Thread Thomas Finneid
Roberts, Jon wrote: PostgreSQL has table partitioning in it so you don't have to dynamically figure out which table to get the data from. I know, but the super table can't handle the number of partition tables I need, 10K-100K tables. Whenever I do a query on the super table, it just aborts

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Alex Vinogradovs
I believe you need to use for execute '...' loop, since the table_name is dynamically composed. Regards, Alex Vinogradovs On Tue, 2008-09-02 at 23:19 +0200, Thomas Finneid wrote: > Hi again, I tried to take the "with" form of the function further to > complete the actual method and met with an

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Roberts, Jon
/ecpg-dynamic.html Jon > -Original Message- > From: [EMAIL PROTECTED] [mailto:pgsql-general- > [EMAIL PROTECTED] On Behalf Of Thomas Finneid > Sent: Tuesday, September 02, 2008 4:19 PM > To: pgsql-general@postgresql.org > Cc: [EMAIL PROTECTED] > Subject: Re: [GENERAL] p

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Raymond O'Donnell
On 02/09/2008 22:19, Thomas Finneid wrote: > for num_list inselect num > from table_part_num_list > where se=se_arg > loop >table_name := 'table_part_'|| num_list.num; > >select * into val_list >from table_name >where st=st_arg

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Raymond O'Donnell
On 02/09/2008 21:55, Thomas Finneid wrote: > with val_list in > select * from tableA > do > loop > return next val_list; > end loop; Oops - my mistake - it should indeed be FOR, not WITH, hence your error message. One other thing in the above - you don't need the DO, i

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Thomas Finneid
Hi again, I tried to take the "with" form of the function further to complete the actual method and met with another error message which I dont understand. I have a number for tables (partitioned) from which I need to retrieve data. Another table keeps track of which tables I should read fro

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Thomas Finneid
Raymond O'Donnell wrote: Can you show us more of your code? I figured out how to make it work when using "for" instead of "with". Here is the code and the error message. I couldnt find anything in the documentation about "with" but I did find something about "for" which I managed to make w

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Raymond O'Donnell
On 02/09/2008 12:18, [EMAIL PROTECTED] wrote: > Does that work in 8.2, cause i get the same error message as I described > above Yep, it does. I should have mentioned that you call your function like this: select * from my_function() - in other words, a SETOF-returning function takes the

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread tfinneid
> Hi there, > > You need to do it like this: > > with val_list in > select * from tableA do > loop > return next val_list; > end loop; > return; > > There's an example here: Does that work in 8.2, cause i get the same error message as I described above regards thoma

Re: [GENERAL] plpgsql returning resultset

2008-09-02 Thread Raymond O'Donnell
On 02/09/2008 11:12, [EMAIL PROTECTED] wrote: > create function test2() returns setof record as > $$ > declare >val_list record; > begin >select * into val_list from tableA; >return next val_list; >return: > end > $$ . Hi there, You need to do it like this: with val_list

[GENERAL] plpgsql returning resultset

2008-09-02 Thread tfinneid
Hi I know the subject has been discussed before, but I dont find what any information that helps me make it work, so please bear with me. In pg 8.2 I want to write a function that gathers data from different tables and joins it into a single resultset, similar to "select * from tableA", but the p