Re: plgpsql and transactions

From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: plgpsql and transactions
Date: 2006-04-06 18:44:57
Message-ID: 200604061444.57241.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thursday 06 April 2006 02:36 pm, Bill Moseley saith:
> In a BEFORE INSERT trigger, depending on input values, I need to lock
> a table and do a few selects. Of course, the "lock table" isn't much
> use if not currently in a transaction.
>
> So my question is this: can I tell if I'm inside a transaction or
> not and issue a BEGIN if not. And then also set a flag so that after
> the INSERT I can detect that I issued a BEGIN and do a COMMIT?
>
> Or, maybe better is to just throw an exception if not already inside a
> transaction.
>
> BTW -- it seems odd to me that you can issue a lock table outside of
> an explicit begin/commit and not get a warning. When would issuing a
> lock table outside an explicit transaction be of any use?
>
>
> --
> Bill Moseley
> moseley(at)hank(dot)org
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

Bill,

Triggers fire inside a transaction.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Douglas McNaught 2006-04-06 19:21:02 Re: Backup method
Previous Message MargaretGillon 2006-04-06 18:41:01 Re: Unique constraint or index, case insensitive, on multiple