Re: Re: PostreSQL SQL for MySQL SQL

Поиск
Список
Период
Сортировка
От Brett W. McCoy
Тема Re: Re: PostreSQL SQL for MySQL SQL
Дата
Msg-id Pine.LNX.4.30.0102061337230.7308-100000@chapelperilous.net
обсуждение исходный текст
Ответ на Re: Re: PostreSQL SQL for MySQL SQL  (John Burski <John.Burski@911ep.com>)
Список 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 по дате отправления:

Предыдущее
От: John Burski
Дата:
Сообщение: Re: Re: PostreSQL SQL for MySQL SQL
Следующее
От: Matthew
Дата:
Сообщение: RE: Re: startup Postgres on NT