Re: Question on how to conditionally commit or rollback a sql-request

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Bergbom Staffan" <Staffan(dot)Bergbom(at)lm(dot)se>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Question on how to conditionally commit or rollback a sql-request
Date: 2010-01-05 00:34:00
Message-ID: 1aa503f7-6b03-4785-96fa-f6d16933e4ff@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bergbom Staffan wrote:

> I get the following error:
> ERROR: SPI execute_plan failed executing query “Commit”:
> SPI_ERROR_TRANSACTION
> CONTEXT: Pl/pgSQL function “objectdescription_bu” line 9 at SQL statement
>
> What does this mean and what should I do to be able to do the desired check

It's not possible to commit or rollback inside a function.
Instead of issuing a rollback, you could raise an exception, and instead of
doing a commit, you should do nothing at all.

Best regards,
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yan Cheng Cheok 2010-01-05 01:12:56 Shall I use PostgreSQL Array Type in The Following Case
Previous Message erobles 2010-01-04 22:55:35 ERROR in createlang