Re: Check the existance of temporary table - Mailing list pgsql-general

From Dmitry Koterov
Subject Re: Check the existance of temporary table
Date
Msg-id d7df81620703251544x30303683k8f6d9cf627293d7@mail.gmail.com
Whole thread Raw
In response to Re: Check the existance of temporary table  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: "Yonatan Ben-Nes"
Date:
Subject: Re: Tsearch2 can't be checked for equality?
Next
From: "amrit angsusingh"
Date:
Subject: Server memory and efficientcy