Re: transactions within stored procedures

From: Thomas Mack <mack(at)ips(dot)cs(dot)tu-bs(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: transactions within stored procedures
Date: 2000-07-14 16:19:17
Message-ID: 200007141619.SAA27684@infbsdb1.idb.cs.tu-bs.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
>By trial and error I established that a SP wraps everything it does in
>one transaction, including anything from stored procedures it calls.
>
>So here is my question: Is there any way for me to control when
>transactions are committed or rolled back within stored procedures? Is

When you invoke a procedure, this invocation is part of a transaction.
You cannot nest transactions so far, as you intend, when you want to
commit or rollback inside of a procedure.

So, when you want your procedure to fail, you would raise an exception,
otherwise, you won't. The invoking program has to react on errors, as it
should do in other situations as well.

For example, select * from xyz fails with an error, when table xyz does
not exist. If you have this statement inside of a transaction, you
would normally react on the error (commit / rollback).

Thomas Mack
TU Braunschweig, Abt. Informationssysteme

Browse pgsql-sql by date

  From Date Subject
Next Message Rodger Donaldson 2000-07-15 05:31:25 Applying SUM twice in the same query.
Previous Message Nathan Young 2000-07-14 16:02:44 transactions within stored procedures