Re: [GENERAL] How to stop implicit rollback on certain errors? - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: [GENERAL] How to stop implicit rollback on certain errors?
Date
Msg-id Pine.LNX.4.20.9912090111190.389-100000@localhost.localdomain
Whole thread Raw
In response to Re: [GENERAL] How to stop implicit rollback on certain errors?  (Lincoln Yeoh <lylyeoh@mecomb.com>)
List 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 by date:

Previous
From: Kevin Heflin
Date:
Subject: get the previous assigned sequence value
Next
From: Lincoln Yeoh
Date:
Subject: Re: [GENERAL] How to stop implicit rollback on certain errors?