Re: SQL error

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: SQL error
Дата
Msg-id 480A0CF1.6010602@postnewspapers.com.au
обсуждение исходный текст
Ответ на SQL error  ("x asasaxax" <xanaruto@gmail.com>)
Список pgsql-general
x asasaxax wrote:
> HI everyone,
>
>
> I´m trying to capture all the possible errors that a statement can have.
> And, if there´s any error i will do a rollback; What i´m trying to do its:
> BEGIN
>   insert into temp values(1, 2, 3);
>   IF ANY_ERROR_OCCURED THEN
>      ROLLBACK;

Sorry, I didn't see the ROLLBACK statement there. Please disregard my
previous reply; I thought you were trying to do something other than
what you appear to be doing.

As Martijn van Oosterhout noted, the transaction will be put in an error
state that ignores further commands. When in an error state, the
transaction will treat COMMIT as ROLLBACK.

I assume you wish to attempt to do something and if it fails, abort the
transaction and leave everything in a working state ready for more
commands? If so, consider doing that at the application level rather
than trying to do it in SQL. All database interfaces give you a way to
find out if an error occurred and get some information about the error.

Maybe if you explained your end goal and why you're trying to do this it
might help people give you more useful answers?

--
Craig Ringer

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: SQL error
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Initial ugly reverse-translator