Re: Transactions, Triggers and Error Messages

From: Richard Huxton <dev(at)archonet(dot)com>
To: Ledina Hido <lh1101(at)ecs(dot)soton(dot)ac(dot)uk>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Transactions, Triggers and Error Messages
Date: 2005-11-09 07:31:01
Message-ID: 4371A5B5.9020909@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ledina Hido wrote:
>
> Thinking about it, the EXCEPTION statement would be inside my user-
> defined function (where I raise the exception in the first place), so I
> cannot see how that would help. As far as I could understand, I cannot
> call "ROLLBACK" (which is what I want to do) inside a user defined
> function. I tried calling it and it was simply ignored. Or am I missing
> something here?

Yes - you want to read up on SAVEPOINTs to handle exceptions at the
applicaton level. You do something like:

SAVEPOINT foo;
...command that works...
...command that works...
...oops, this one gives me an error...
ROLLBACK TO SAVEPOINT foo;

Exceptions in plpgsql are just a wrapper to this process.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Orhan 2005-11-09 08:04:40 temporary tables
Previous Message Riaan van der Westhuizen 2005-11-09 07:00:08 Debian packages