Re: Drop temporary table only if it exists

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Mintoo Lall <tlqmail(at)yahoo(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Drop temporary table only if it exists
Date: 2003-02-14 17:48:15
Message-ID: 200302140948.15889.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mintoo,

> How do I drop a temporary table ( or for that matter a sequence) only if it
> exists or create them if they donot exist ? I want to do this to avoid any
> errors

A quick check for existance:

SELECT * FROM pg_class WHERE relname = 'name_of_temp_table' and relkind = ?

You'll want to look in the docs about the PG system tables to see what
"relkind" you should test on for each type of object.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2003-02-14 18:00:52 Re: Timezone conversion
Previous Message Tambet Matiisen 2003-02-14 16:25:02 Re: PL/PGSQL EDITOR