X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 6A790475957 for ; Fri, 14 Feb 2003 13:12:19 -0500 (EST) Received: from web14802.mail.yahoo.com (web14802.mail.yahoo.com [216.136.224.218]) by postgresql.org (Postfix) with SMTP id B3FA44758E6 for ; Fri, 14 Feb 2003 13:12:15 -0500 (EST) Message-ID: <20030214181214.75346.qmail@web14802.mail.yahoo.com> Received: from [66.139.15.154] by web14802.mail.yahoo.com via HTTP; Fri, 14 Feb 2003 10:12:14 PST Date: Fri, 14 Feb 2003 10:12:14 -0800 (PST) From: Mintoo Lall Subject: Re: Drop temporary table only if it exists To: Josh Berkus , pgsql-sql@postgresql.org In-Reply-To: <200302140948.15889.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-778709281-1045246334=:73625" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/340 X-Sequence-Number: 11738 --0-778709281-1045246334=:73625 Content-Type: text/plain; charset=us-ascii Thanks Josh Berkus 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 --0-778709281-1045246334=:73625 Content-Type: text/html; charset=us-ascii

Thanks

 Josh Berkus <josh@agliodbs.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 --0-778709281-1045246334=:73625--