Re: transaction problem using cursors

From: Thomas Pundt <mlists(at)rp-online(dot)de>
To: pgsql-general(at)postgresql(dot)org
Cc: "Pit M(dot)" <fmi-soft(at)gmx(dot)de>
Subject: Re: transaction problem using cursors
Date: 2007-06-11 12:48:20
Message-ID: 200706111448.20432.mlists@rp-online.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)pundt(at)rp-online(dot)de> ---- http://rp-online.de/ ----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alexander Staubo 2007-06-11 13:08:07 Re: Distributing PostGres database to various customers
Previous Message Ray Stell 2007-06-11 12:43:02 Re: track ddl changes on single database