Re: Re: PostreSQL SQL for MySQL SQL

From: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
To: John Burski <John(dot)Burski(at)911ep(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: PostreSQL SQL for MySQL SQL
Date: 2001-02-06 18:42:22
Message-ID: Pine.LNX.4.30.0102061337230.7308-100000@chapelperilous.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 6 Feb 2001, John Burski wrote:

> There is no "if exists" functionality in PostgreSQL. However, you could
> probably create your own "if exists" type of functionality. I've found that
> it's not really necessary. I access my databases either interactively, via
> psql, via the Perl Pg module, or via PHP. If you attempt to drop a database
> that doesn't exist, PostgreSQL will issue an error message. If you're running
> interactively, you'll see the message; if you're accessing via a Perl module or
> PHP, you can check the query results to see if an error occurred. I'm fairly
> certain that this same mechanism exists if you're using C or C++ to access your
> databases.

If you are using Perl, if you wrap your attempt to drop the table in an
eval statement and then check for anything in $@, you can see if an
exception was thrown without having anything mess up your display and
still have the appropriate logic for testing the existance of the table.
This is more or less the equivalent to doing 'try... catch' in Java or
C++.

-- Brett
http://www.chapelperilous.net/~bmccoy/
---------------------------------------------------------------------------
When God saw how faulty was man He tried again and made woman. As to
why he then stopped there are two opinions. One of them is woman's.
-- DeGourmont

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Burski 2001-02-06 19:10:21 Re: Re: PostreSQL SQL for MySQL SQL
Previous Message Brice Ruth 2001-02-06 18:07:03 Re: SQL Join - MySQL/PostgreSQL difference?