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.