Re: Re: PostreSQL SQL for MySQL SQL - Mailing list pgsql-general

From Brett W. McCoy
Subject Re: Re: PostreSQL SQL for MySQL SQL
Date
Msg-id Pine.LNX.4.30.0102061337230.7308-100000@chapelperilous.net
Whole thread Raw
In response to Re: Re: PostreSQL SQL for MySQL SQL  (John Burski <John.Burski@911ep.com>)
List 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


pgsql-general by date:

Previous
From: John Burski
Date:
Subject: Re: Re: PostreSQL SQL for MySQL SQL
Next
From: Matthew
Date:
Subject: RE: Re: startup Postgres on NT