Re: Getting rows in statement-level triggers

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: Artacus <artacus(at)comcast(dot)net>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting rows in statement-level triggers
Date: 2008-10-03 06:57:56
Message-ID: 65937bea0810022357g5e585f70p3ca07d06af2f93c0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Oct 3, 2008 at 11:42 AM, Artacus <artacus(at)comcast(dot)net> wrote:

>
> So the manual says there is no way for a statement-level trigger to
>> examine the row(s) modified by the statement.
>>
>> Is there any way to get the xmin or cmin of the transaction that fired the
>> trigger? Or can I look up the last xid for a table some where?
>>
>
> Ok, so it took a lot of googling to figure this one out, but you can do it
> with something like so.
>
> SELECT *
> FROM strand_scores
> WHERE xmin::text = txid_current()::text
>
> It appears you can't convert a xid type to int or bigint, not sure why. I
> guess I should leave a comment on the manual page.

That's an interesting find, i'd say.

xmin::bigint doesn't work because that implicit CAST doesn't exist. If
needed, I'd use xmin::text::bigint; that should work.

Best regards,
--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Leif B. Kristensen 2008-10-03 09:43:58 Re: Import German Number Format
Previous Message Asko Oja 2008-10-03 06:30:46 Re: [HACKERS] Transactions within a function body