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

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Lincoln Yeoh <lylyeoh(at)mecomb(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] How to stop implicit rollback on certain errors?
Date: 1999-12-09 00:18:48
Message-ID: Pine.LNX.4.20.9912090111190.389-100000@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 1999-12-09 01:23:35 Re: [GENERAL] How to stop implicit rollback on certain errors?
Previous Message Kevin Heflin 1999-12-08 22:40:58 get the previous assigned sequence value