raise exception and transaction handling

From: "Marcin Krawczyk" <jankes(dot)mk(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: raise exception and transaction handling
Date: 2007-07-28 20:54:21
Message-ID: 95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,
I have a problem with transaction
handling. What I need to do is execute an INSERT command that would
not be canceled by the
RAISE EXCEPTION command in AFTER UPDATE TRIGGER. A piece of code:

BEGIN
-- some computations

bledne := (SELECT g.q_sumka('Poz.' || lps || ' - min. cena: ' || cena || ' '
|| waluta ||'; ') FROM g.m_lista WHERE idf = NEW.id);

IF EXISTS (SELECT 1 FROM g.m_lista WHERE idf = NEW.id) THEN
RAISE EXCEPTION 'CENY NIE SPELNIAJA WARUNKOW! %', rtrim(bledne);
BEGIN
INSERT INTO g.m_proba VALUES (1,2); -- this is the operation I need to
perform but the RAISE EXCEPTION above cancels it out
PREPARE TRANSACTION 'a';
COMMIT PREPARED 'a';
END;
END IF;

I tried to do it as shown above, with PREPARE and COMMIT but it's not
working.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Michal Kedziora 2007-07-29 11:33:25 Re: raise exception and transaction handling
Previous Message Michael Glaesemann 2007-07-27 20:43:03 Re: group by range of values