Re: transaction problem using cursors - Mailing list pgsql-general

From Thomas Pundt
Subject Re: transaction problem using cursors
Date
Msg-id 200706111448.20432.mlists@rp-online.de
Whole thread Raw
In response to transaction problem using cursors  ("Pit M." <fmi-soft@gmx.de>)
Responses Re: transaction problem using cursors  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Re: transaction problem using cursors  ("Pit M." <fmi-soft@gmx.de>)
List pgsql-general
Hi,

On Monday 11 June 2007 13:45, Pit M. wrote:
| Assume a user doing a query which shall select all customers having a
| ZIP in [10000;20000[ by using a CAST. If the cursor now fetches the row
| with ID 4 we get an error (invalid input syntax) as "A1234" cannot be
| casted as integer. This is ok, BUT now all further FETCH commands fail
| with "current transaction is aborted"!
|
| How can we resume from there with FETCH commands (e.g. at least FETCH
| FIRST)? We cannot avoid the (first) error itself, as the user can enter
| any WHERE condition at runtime. Therefore we must handle the error - if
| any - and resume from there properly.

I didn't try myself, but wrapping the whole into a PL/pgSQL function and
using exceptions might do the work;

http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Ciao,
Thomas

--
Thomas Pundt <thomas.pundt@rp-online.de> ---- http://rp-online.de/ ----

pgsql-general by date:

Previous
From: Ray Stell
Date:
Subject: Re: track ddl changes on single database
Next
From: "Alexander Staubo"
Date:
Subject: Re: Distributing PostGres database to various customers