Re: Transactions in rules..

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: Transactions in rules..
Дата
Msg-id 200107091448.f69Emb707462@jupiter.us.greatbridge.com
обсуждение исходный текст
Ответ на Transactions in rules..  ("Fabrizio Mazzoni" <fabrizio@macron.com>)
Список pgsql-general
Fabrizio Mazzoni wrote:
> Can i use transactions in rules??
> I was trying something like:
>
> create rule x_test as
> on insert to view1
> do instead
> (
>    begin;
>    insert into test1 values (new.a,new.b);
>    insert into test2 values (new.c,new.d);
>    commit;
> );
>
> But when i give this command in psql i always get an error..

    There  is  no  way  to  execute  a statement without having a
    transaction  in  PostgreSQL.  If  you're  not  inside  of   a
    transaction  block,  even  a  simple  SELECT  from the client
    (psql, application) will have it's own transaction.

    For your above case, if you don't do BEGIN/COMMIT, the INSERT
    will  have  it's  own Xact with automatic COMMIT (if no ERROR
    happens).  The rule actions will allways belong to  the  same
    Xact  the INSERT does, so either all is committed or nothing.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: problems with rules and views
Следующее
От: Jan Wieck
Дата:
Сообщение: Re: fmgr_info: function 2714160: cache lookup failed