Re: if exists ...

From: Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr>
To: Andreas Schlegel <schlegelaw(at)gmx(dot)de>, Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: if exists ...
Date: 2003-01-11 11:19:11
Message-ID: 200301111119.11640.darko.prenosil@finteh.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 10 January 2003 14:02, Andreas Schlegel wrote:
> Hi,
>
> writing Postgres SQL scripts I have the problem: how do I check if a
> database object already exists?
>
> Having a list of create table, create trigger, create view ...
> statements I have to decide if the script first drops the existing old
> object or if it doesn't already exist to create it without dropping.
>
> Transact-Sql allows the following construct:
> if exists (select * from sysobjects where id = object_id(...) = 1)
> drop trigger tCompUTrig
> GO
>
> I know that postgres has the "table_exists" function. But I don't know
> the syntax to integrate it in a script with create and drop statements.
>
> Any ideas?
>
> Greetings,
> Andreas
>
>

Maybe functions I wrote can help. You can find it at:
http://www.brasileiro.net:8080/postgres/cookbook/view-one-recipe.adp?recipe_id=4448
Regards.

>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message CSN 2003-01-11 18:10:05 PG Article: Moving Logic Into the Database
Previous Message Christoph Dalitz 2003-01-11 08:02:14 Re: Demo System...