Re: DROP TYPE without error?

From: Mischa <mischa(dot)Sandberg(at)telus(dot)net>
To: Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: DROP TYPE without error?
Date: 2005-04-06 20:03:27
Message-ID: 1112817807.4254408fecadc@webmail.telus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Quoting Philippe Lang <philippe(dot)lang(at)attiksystem(dot)ch>:

> Since it is not possible to use CREATE OR REPLACE TYPE, is there a way
> of using DROP TYPE on a non-existing type, without causing the entire
> script to abort? It may sound crazy to ask for this, but it could be
> really useful in my case, where Pl/Pgsql and Pl/Perl code is being
> generated automatically, based on data found in a database.

I've got a similar request for other objects that do/do not exist.
Maybe it's just that I got lazy using MSSQL, but it sure was convenient
to have:

IF object_id('WorkTable') IS NULL
CREATE TABLE WorkTable(...
etc.

Given that you cannot just execute an anonymous block of PL/PGSQL code,
where you could do the test AND the create ...

--
"Dreams come true, not free."

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2005-04-06 20:30:44 Re: Problems with Set Returning Functions (SRFs)
Previous Message Otto Blomqvist 2005-04-06 18:53:45 Problems with Set Returning Functions (SRFs)