pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marcin Krawczyk <jankes.mk@gmail.com>
To: pgsql-sql@postgresql.org
Subject: raise exception and transaction handling
Date: Sat, 28 Jul 2007 22:54:21 +0200
Message-ID: <95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com> (raw)

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.

view thread (3+ messages)  latest in thread

Message-ID: <95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com>
Permalink:  ../95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com/
Also on:    postgresql.org/message-id/95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jankes.mk@gmail.com
  Subject: Re: raise exception and transaction handling
  In-Reply-To: <95f6bf9b0707281354n2f4772abmaba91132c466b3ac@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox