Re: [GENERAL] How to stop implicit rollback on certain errors?

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: [GENERAL] How to stop implicit rollback on certain errors?
Дата
Msg-id Pine.LNX.4.20.9912090111190.389-100000@localhost.localdomain
обсуждение исходный текст
Ответ на Re: [GENERAL] How to stop implicit rollback on certain errors?  (Lincoln Yeoh <lylyeoh@mecomb.com>)
Список pgsql-general
On 1999-12-08, Lincoln Yeoh mentioned:

> begin;
> insert into stuff;
> do some nondatabase things based on last inserted id;
> update a date in stuff;
> commit;
>
> It seems that if the date is out of the database range, everything is
> thrown out. Is it possible to catch the database error and use a null date
> instead, without throwing everything away?

Yes, use no transaction at all. :)

Seriously, why do you use a transaction, when you don't want any errors
caught? Transactions are defined as everything succeeds or nothing goes.
If you want update to succeed anyhow, put it in it's own transaction
(i.e., commit before it).

> I guess that's expected, and I should insert big years using another less
> ambiguous format. What is the recommended format?

The safest way would be to set a date format with SET DATESTYLE TO and use
that, possibly assisted by library formatting routines.

--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



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

Предыдущее
От: Kevin Heflin
Дата:
Сообщение: get the previous assigned sequence value
Следующее
От: Lincoln Yeoh
Дата:
Сообщение: Re: [GENERAL] How to stop implicit rollback on certain errors?