Re: [HACKERS] [GENERAL] Transactions within a function body

2008-10-02 Thread Asko Oja
On Thu, Oct 2, 2008 at 6:46 PM, Bob Henkel <[EMAIL PROTECTED]> wrote: > Have you looked at creating a function in perl and creating a new > connection? Or using a dblink query which can create a new connection? > These two methods work. I have used them to insert to a log table regardless > of the

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Gurjeet Singh
No, in Oracle too SAVEPOINT and AUTONOMOUS transaction are different beasts. On Thu, Oct 2, 2008 at 9:27 PM, Bob Henkel <[EMAIL PROTECTED]> wrote: > Coming from an Oracle background my understanding is they're one in the > same. > > > > > On Thu, Oct 2, 2008 at 10:37 AM, Alvaro Herrera < > [EMAIL

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Bob Henkel
Coming from an Oracle background my understanding is they're one in the same. On Thu, Oct 2, 2008 at 10:37 AM, Alvaro Herrera <[EMAIL PROTECTED]>wrote: > Bob Henkel escribió: > > Have you looked at creating a function in perl and creating a new > > connection? Or using a dblink query which can

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Bob Henkel
Have you looked at creating a function in perl and creating a new connection? Or using a dblink query which can create a new connection? These two methods work. I have used them to insert to a log table regardless of the parent transaction being commited or rolled back. A old example I posted of u

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Alvaro Herrera
Gurjeet Singh escribió: > I have seen this feature being asked for, and this work-around suggested so > many times. If plpgql does it internally, why not provide a clean interface > for this? Is there some road-block, or that nobody has ever tried it? Initially we aimed at just exposing SAVEPOINT

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Alvaro Herrera
Bob Henkel escribió: > Have you looked at creating a function in perl and creating a new > connection? Or using a dblink query which can create a new connection? > These two methods work. I have used them to insert to a log table regardless > of the parent transaction being commited or rolled back.

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Gurjeet Singh
On Thu, Oct 2, 2008 at 8:40 PM, Alvaro Herrera <[EMAIL PROTECTED]>wrote: > Reg Me Please escribió: > > Il Thursday 02 October 2008 16:15:10 Alvaro Herrera ha scritto: > > > > You can nest blocks arbitrarily, giving you the chance to selectively > > > rollback pieces of the function. It's only a b

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Bob Henkel
Have you looked at creating a function in perl and creating a new connection? Or using a dblink query which can create a new connection? These two methods work. I have used them to insert to a log table regardless of the parent transaction being commited or rolled back. A old example I posted of u

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Reg Me Please escribió: >> You mean I can issue a ROLLBACK command within a BEGIN...END; block to roll >> it >> back? > No -- I mean you can use BEGIN/EXCEPTION/END blocks as you like, nesting > them or putting one after another. Complementing this w

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Reg Me Please
Il Thursday 02 October 2008 17:10:23 Alvaro Herrera ha scritto: > Reg Me Please escribió: > > Il Thursday 02 October 2008 16:15:10 Alvaro Herrera ha scritto: > > > You can nest blocks arbitrarily, giving you the chance to selectively > > > rollback pieces of the function. It's only a bit more awkw

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Alvaro Herrera
Reg Me Please escribió: > Il Thursday 02 October 2008 16:15:10 Alvaro Herrera ha scritto: > > You can nest blocks arbitrarily, giving you the chance to selectively > > rollback pieces of the function. It's only a bit more awkward. > > You mean I can issue a ROLLBACK command within a BEGIN...END;

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Reg Me Please
Il Thursday 02 October 2008 16:15:10 Alvaro Herrera ha scritto: > Reg Me Please escribió: > > Well, if it is a limitation, and having it would lead to a "better > > product", why not making it a feature for the next still-open release? > > Because no one is working on implementing it? > > > In my o

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Alvaro Herrera
Reg Me Please escribió: > Well, if it is a limitation, and having it would lead to a "better product", > why not making it a feature for the next still-open release? Because no one is working on implementing it? > In my opinion that's more than a limitation, it's a missing feature. > In your code

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Albe Laurenz
Richard Huxton wrote: >> After a discussion on comp.databases.postgresql I realized that this >> is actually a limitation. >> >> Consider the following: >> >> BEGIN >>UPDATE ... >>UPDATE ... >>UPDATE ... >> EXCEPTION >>WHEN integrity_constraint_violation THEN >> ... >> END;

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Reg Me Please
Hi. My humble opinion follows. One point here is that the decision for the ROLLBACK could possibly be different from errors. It could simply be based upon a generic expression, not just the conditions seen in "Appendix A" of the manual. An exception is something different from a transaction, de

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Reg Me Please
Well, if it is a limitation, and having it would lead to a "better product", why not making it a feature for the next still-open release? In my opinion that's more than a limitation, it's a missing feature. In your code you often need to create savepoints to delay the decision for the commitment.

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Richard Huxton
Albe Laurenz wrote: > After a discussion on comp.databases.postgresql I realized that this > is actually a limitation. > > Consider the following: > > BEGIN >UPDATE ... >UPDATE ... >UPDATE ... > EXCEPTION >WHEN integrity_constraint_violation THEN > ... > END; > > If the fir

Re: [GENERAL] Transactions within a function body

2008-10-02 Thread Albe Laurenz
Alvaro Herrera wrote: > > > Is there a way to have (sub)transactions within a function body? > > > I'd like to execute some code (a transaction!) inside a function and later > > > decide whether that transaction is to be committed or not. > > > > You could issue a "SAVEPOINT name". If at the end y

Re: [GENERAL] Transactions within a function body

2008-10-01 Thread Alvaro Herrera
Dennis Brakhane escribió: > On Wed, Oct 1, 2008 at 5:54 PM, Reg Me Please <[EMAIL PROTECTED]> wrote: > > Hi all. > > > > Is there a way to have (sub)transactions within a function body? > > I'd like to execute some code (a transaction!) inside a function and later > > decide whether that transactio

Re: [GENERAL] Transactions within a function body

2008-10-01 Thread Dennis Brakhane
On Wed, Oct 1, 2008 at 5:54 PM, Reg Me Please <[EMAIL PROTECTED]> wrote: > Hi all. > > Is there a way to have (sub)transactions within a function body? > I'd like to execute some code (a transaction!) inside a function and later > decide whether that transaction is to be committed or not. You coul

[GENERAL] Transactions within a function body

2008-10-01 Thread Reg Me Please
Hi all. Is there a way to have (sub)transactions within a function body? I'd like to execute some code (a transaction!) inside a function and later decide whether that transaction is to be committed or not. Thanks. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make c

Re: [GENERAL] Transactions within a function body

2008-10-01 Thread Andreas Kretschmer
Reg Me Please <[EMAIL PROTECTED]> schrieb: > Hi all. > > Is there a way to have (sub)transactions within a function body? No. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) "If I was