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. # #================================================== [EMAIL PROTECTED] # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]