Re: Help with SET TRANSACTION in a function - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Help with SET TRANSACTION in a function
Date
Msg-id 20020304221149.J86530-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Help with SET TRANSACTION in a function  ("otisg" <otisg@iVillage.com>)
List 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.


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: FATAL 2: RelationPutHeapTuple: failed to add tuple
Next
From: thiemo
Date:
Subject: Compiling problems