Re: Drop temporary table only if it exists

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


Thanks
Josh Berkus <josh(at)agliodbs(dot)com> wrote: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

---------------------------------
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Brad Hilton 2003-02-14 18:22:19 sub-query optimization
Previous Message Stephan Szabo 2003-02-14 18:00:52 Re: Timezone conversion