Re: Transactions in user defined function

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: Jasid ZA <za(dot)jasid(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Transactions in user defined function
Date: 2009-03-13 14:44:58
Message-ID: 49BA716A.5030804@wildenhain.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Grzegorz Jaśkiewicz wrote:
> On Fri, Mar 13, 2009 at 12:03 PM, Jasid ZA <za(dot)jasid(at)gmail(dot)com> wrote:
>> Hi,
>>
>> Can we use sql transaction(BEGIN, COMMIT, REVOKE) inside a user defined
>> function in Postgresql 8.3?
>>
>> looking forward to hear from you
>
> Nope.
> If function does something naughty - do RAISE EXCEPTION, that will
> break transaction and query (hence rollback).
> Please notice, that in plpgsql function uses BEGIN and END, and those
> are precisely there to start and end transaction.

Sorry, they are not:

"It is important not to confuse the use of BEGIN/END for grouping
statements in PL/pgSQL with the similarly-named SQL commands for
transaction control. PL/pgSQL's BEGIN/END are only for grouping; they do
not start or end a transaction."

Regards
Tino

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2009-03-13 14:55:28 Re: Inserting string with a " into an array using {} syntax ... possible?
Previous Message Tino Wildenhain 2009-03-13 14:43:53 Re: Transactions in user defined function