Temp table exists test??

From: Michael Guerin <guerin(at)rentec(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Temp table exists test??
Date: 2005-02-04 01:16:30
Message-ID: 4202CCEE.90806@rentec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi All,

Is there a way to find out the namespace id (relnamespace) for your
connection? I grabbed this function from one of the list, however it
doesn't work for temp tables when multiple connections are involved b/c
it will always return true.

Thanks
Michael
-------------------
CREATE OR REPLACE FUNCTION table_exists("varchar")
RETURNS bool AS
$BODY$

DECLARE
t_name ALIAS for $1;
t_result VARCHAR;
BEGIN
--find table, case-insensitive
SELECT relname INTO t_result
FROM pg_class
WHERE relname ~* ('^' || t_name || '$')
AND relkind = 'r';
IF t_result IS NULL THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END IF;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Michael Fuhr 2005-02-04 01:31:19 Re: Storing latitude and longitude
Previous Message Rodolfo J. Paiz 2005-02-04 00:31:45 Storing latitude and longitude