Transaction in plpgsql function?
Transaction in plpgsql function?
От:
"MaFa" <mafalista@freemail.hu>
Дата:
Hi All, could someone tell me, how can I start explicitly a transaction in a plpgsql function? The begin/commit doesn't work.. :-( Thanks! MaFa
Re: Transaction in plpgsql function?
От:
Oliver Elphick <olly@lfix.co.uk>
Дата:
On Sun, 2003-11-23 at 11:39, MaFa wrote:
> Hi All,
>
> could someone tell me, how can I start explicitly a transaction in a plpgsql
> function? The begin/commit doesn't work.. :-(
You don't. All of a function takes place inside a transaction. If
there is no explicit transaction already, an implicit one will have been
started.
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"The LORD is nigh unto all them that call upon him, to
all that call upon him in truth."
Psalms 145:18
Re: Transaction in plpgsql function?
От:
"MaFa" <mafalista@freemail.hu>
Дата:
> You don't. All of a function takes place inside a transaction. If > there is no explicit transaction already, an implicit one will have been > started. If it is true, then the following function why causes sometimes a "duplicate row"' error? begin if exists(select session_data from session where session_id= $1 ) then update session set session_data= $2, session_exp=now() + interval ''10 minutes'' where session_id= $1 ; return 0; else insert into session(session_id, session_exp, session_data) values ($1 , now() + interval ''10 minutes'' , $2); return 1; end if; end; Maybe because of the current isolation level? Thanks: MaFa