Re: Getting rows in statement-level triggers - Mailing list pgsql-general

From Artacus
Subject Re: Getting rows in statement-level triggers
Date
Msg-id 48E5B7B5.2070903@comcast.net
Whole thread Raw
In response to Getting rows in statement-level triggers  (Artacus <artacus@comcast.net>)
Responses Re: Getting rows in statement-level triggers  ("Gurjeet Singh" <singh.gurjeet@gmail.com>)
Re: Getting rows in statement-level triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
> 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.



pgsql-general by date:

Previous
From: Klint Gore
Date:
Subject: Re: How do I save data and then raise an exception?
Next
From: "Asko Oja"
Date:
Subject: Re: [HACKERS] Transactions within a function body