Search Postgresql Archives

Re: plpgsql returning resultset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/09/2008 22:19, Thomas Finneid wrote:
>     for num_list in    select 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 and tr=tr_arg;
> 
>        return next val_list;

I think you need to build the query dynamically as a string, then
execute it using EXECUTE:

http://www.postgresql.org/docs/8.3/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

So something like this (I haven't tried it):

  loop
    execute 'select * into val_list from '
      || 'table_part_' || num_list.num
      || ' where st = st_arg and tr = tr_arg';
    return next val_list;
  end loop;

Hopefully this will work.

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@xxxxxx
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux