Re: temp tables in functions?

Поиск
Список
Период
Сортировка
От Shoaib Mir
Тема Re: temp tables in functions?
Дата
Msg-id bf54be870702072329v75f8d1fbm1e5201a960efd566@mail.gmail.com
обсуждение исходный текст
Ответ на Re: temp tables in functions?  (Bruno Wolff III <bruno@wolff.to>)
Ответы Re: temp tables in functions?  (Michael Fuhr <mike@fuhr.org>)
Список pgsql-general
Something like this will help you:

execute immediate 'create temporary table test (a number) on commit drop';

--
Shoaib Mir
EnterpriseDB ( www.enterprisedb.com)

On 2/8/07, Bruno Wolff III <bruno@wolff.to> wrote:
On Wed, Feb 07, 2007 at 20:40:09 -0800,
  jws <jsacksteder@gmail.com> wrote:
> Having developed a complex query, I want to wrap it up as a function
> so that it can take a parameter and return a set of rows. This query
> is currently written as multiple sql statements that create a few
> interstitial temp tables that are then joined. If I put this into a
> function definition, do those temp tables get dropped automatically
> when the function returns?

See: http://www.postgresql.org/docs/8.2/interactive/sql-createtable.html
So, the answer is no.

Also note that currently Postgres will cache information about tables
used in functions and this may not work well when you are dropping and
recreating tables with the same name in the same session. For that kind
of thing you need to use EXECUTE to avoid caching.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

В списке pgsql-general по дате отправления:

Предыдущее
От: Shane Ambler
Дата:
Сообщение: Re: accidentally deleted user --> postgres
Следующее
От: brian
Дата:
Сообщение: Re: 'greatest' function?