Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: basic stored proc/transaction question


  • From: Ben <bench(at)silentmedia(dot)com>
  • To: Ian Harding <harding(dot)ian(at)gmail(dot)com>
  • Cc: pgsql-general(at)postgresql(dot)org
  • Subject: Re: basic stored proc/transaction question
  • Date: Fri, 24 Mar 2006 10:31:31 -0800 (PST)
  • Message-id: <Pine(dot)LNX(dot)4(dot)64(dot)0603241026530(dot)15001(at)localhost(dot)localdomain>

Well, that's awesome. Thanks!

On Fri, 24 Mar 2006, Ian Harding wrote:

On 3/24/06, Ben <bench(at)silentmedia(dot)com> wrote:
My understanding is that a stored procedure does an implicit begin/commit when
it executes. Maybe my brain isn't working so well this morning, because I can't
figure out how I would do:

begin;
call stored proc;
call another stored proc;
commit;

It seems that the transaction would be committed after the first call.

Nope.  Unless you use the new SAVEPOINT stuff, the explicit
transaction is the transaction.  Any error in any function will
rollback the whole thing.  The commit happens at the explicit commit.

Every SQL statement (such as calling a function) runs in an implicit
transaction.  Explicit transactions effectively "group" these implicit
transactions such that any one failure causes them all to fail.

- Ian




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group