Re: how to detect errors in statements piped to psql?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: how to detect errors in statements piped to psql?
Дата
Msg-id 20030225074834.GA28004@svana.org
обсуждение исходный текст
Ответ на how to detect errors in statements piped to psql?  (Drew Wilson <amw@speakeasy.net>)
Список pgsql-general
If you do them all in one session and surround them with BEGIN and COMMIT
then it'll become an all or nothing affair.

On Mon, Feb 24, 2003 at 06:29:27PM -0800, Drew Wilson wrote:
> I'm trying to script some updates to system tables, and I can't figure
> out how to detect an error condition in the SQL sent to psql.
>
> Is there anyway to test for errors returned by psql?
>
> For example:
>  echo "select foo from pg_database" | psql -U admin myDB || echo
> "failed" && echo "success"
>
> This doesn't work. Neither "failed" nor "success" are echoed.
> Only 'ERROR:  Attribute "foo" not found' is displayed on console.
>
>
> Alternatively, is there a way to do this as a single transaction, that
> will rollback if any statement fails? (Without installing PL/pgSQL,
> that is.)
>
>
> TIA,
>
> Drew
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Support bacteria! They're the only culture some people have.

Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: Drew Wilson
Дата:
Сообщение: how to detect psql's errors?
Следующее
От: Antti Haapala
Дата:
Сообщение: Re: How do I change the server encoding?