Re: Help with SET TRANSACTION in a function

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: otisg <otisg(at)iVillage(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Help with SET TRANSACTION in a function
Date: 2002-03-05 06:15:46
Message-ID: 20020304221149.J86530-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 4 Mar 2002, otisg wrote:

> > Only declarations go outside the begin. As far as I can see, you
> > really just can't put a set transaction isolation level in a function
> > and expect it to work. If PostgreSQL had nested transactions you could
> > presumably do it then, but it doesn't.
>
> So how does one use SET TRANSACTION...?
> I have not been able to find any examples of that in the docs, other
> than the reference document.
> Could you please provide a simple example of how SET TRANSACTION... is
> used?

You use it directly in the sequence of sql commands (for example in psql)
begin;
set transaction isolation level serializable;
select funcfoo();
select * from sometable;
update sometable set somevalue=3 where somevalue=4;
end;

AFAICS you just can't use it inside a function since it needs to be before
the first query the transaction does (the error message it gives otherwise
basically says so anyway) and to get to a function means you're already
processing a query.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message thiemo 2002-03-05 06:33:48 Compiling problems
Previous Message Tom Lane 2002-03-05 05:49:39 Re: FATAL 2: RelationPutHeapTuple: failed to add tuple