Re: how to detect errors in statements piped to psql?
Вложения
В списке pgsql-general по дате отправления:
| От | 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 по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера