Re: Check the existance of temporary table

Поиск
Список
Период
Сортировка
От Dmitry Koterov
Тема Re: Check the existance of temporary table
Дата
Msg-id d7df81620703251544x30303683k8f6d9cf627293d7@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Check the existance of temporary table  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
In stored procedures I used something like

BEGIN
    CREATE TEMPORARY TABLE tmp ...
EXCEPTION
    WHEN ... THEN ...
END

See pg error codes for details (I don't remember exactly, but maybe it is a dumplicate_table or duplicate_object exception).

On 3/25/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"dfx" <dfx@dfx.it> writes:
> how I can check  the existance of temporary table?
> I.e. wich query I have to use to know if MY_TEMP_TABLE exists?

As of 8.2 you can do

SELECT ... FROM pg_class
  WHERE relname = 'whatever' AND relnamespace = pg_my_temp_schema();

In earlier releases pg_my_temp_schema() isn't built in, so you have
to do some pushups to determine which schema is your temp schema.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

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

Предыдущее
От: "Yonatan Ben-Nes"
Дата:
Сообщение: Re: Tsearch2 can't be checked for equality?
Следующее
От: "amrit angsusingh"
Дата:
Сообщение: Server memory and efficientcy