Обсуждение: select from a dynamic table name

Поиск
Список
Период
Сортировка

select from a dynamic table name

От
"Jason Kwok"
Дата:
Since I could return a rowset (some records) from a function of pgsql or
plpgsql, I saved all the records into a temp file. Then I want to get the
rowset by another select statement from this temp table with dynamic name,
could I do something like the folowing :

select * from a_dynamic_table_name ?

If the a_dynamic_table_name could be specified as a function, it would be
great, because inside the function I could insert the needed rows into the
temp file and then return its name for the select statement. Is this
possible?

==
====
Best Regards
Jason Kwok
==============
====


---
Virus Free
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.292 / Virus Database: 157 - Release Date: 2001/10/26



Re: select from a dynamic table name

От
David Stanaway
Дата:
On Friday, November 2, 2001, at 05:58  PM, Jason Kwok wrote:

> Since I could return a rowset (some records) from a function of pgsql or
> plpgsql, I saved all the records into a temp file. Then I want to get 
> the
> rowset by another select statement from this temp table with dynamic 
> name,
> could I do something like the folowing :
>
> select * from a_dynamic_table_name ?

How about

exec 'select * from '&somefunc();

Where somefunc() returns the name of the temporary table.
You'll have to delete it after, so it will be a little more messy.

There was talk in the list on functions returning record sets being a 
feature of 7.2 and there being some patches for 7.1 that permited it.

Jan Wieck <JanWieck@Yahoo.com> Wrote on Wed Aug 15, 2001  03:49:03  PM 
Australia/Sydney
>     As  said,  in  v7.2  we'll have the ability to return cursors
>     from functions (and I'm looking actually into the ability  of
>     doing  RETURN AND RESUME).  So there is at least some sort of
>     workaround on the horizon.


==============================
David Stanaway
Personal: david@stanaway.net
Work: david@netventures.com.au