pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: DAVID ROTH <adaptron@comcast.net>
To: Christophe Pettus <xof@thebuild.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Trigger Function question
Date: Mon, 10 Jul 2023 14:29:59 -0400 (EDT)
Message-ID: <1715546791.171305.1689013799237@connect.xfinity.com> (raw)
In-Reply-To: <DF18ED9A-83D1-4CE8-888F-2BF3393CD9A3@thebuild.com>
References: <1875078143.170839.1689013230630@connect.xfinity.com>
	<DF18ED9A-83D1-4CE8-888F-2BF3393CD9A3@thebuild.com>

I want to use a single trigger function to log multiple tables and the tables have different columns.  I can get the names of the columns from the catalog.  But I have not been able to figure out how to get NEW.x when x is not known until run time.


> On 07/10/2023 2:23 PM EDT Christophe Pettus <xof@thebuild.com> wrote:
> 
>  
> > On Jul 10, 2023, at 11:20, DAVID ROTH <adaptron@comcast.net> wrote:
> > 
> > In a trigger function, is there a way to get a list of all of the columns in the triggering table?
> 
> You can get the table that the trigger fired on with TG_TABLE_SCHEMA and TG_TABLE_NAME, and then query the system catalogs to get a list of columns.
> 
> But can you tell us a bit more about your use-case?  You may be able to write the trigger in such a way that it doesn't need to change behavior based on the columns.





view thread (12+ messages)  latest in thread

Message-ID: <1715546791.171305.1689013799237@connect.xfinity.com>
Permalink:  ../1715546791.171305.1689013799237@connect.xfinity.com/
Also on:    postgresql.org/message-id/1715546791.171305.1689013799237@connect.xfinity.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adaptron@comcast.net, xof@thebuild.com
  Subject: Re: Trigger Function question
  In-Reply-To: <1715546791.171305.1689013799237@connect.xfinity.com>
  References: <1875078143.170839.1689013230630@connect.xfinity.com> <DF18ED9A-83D1-4CE8-888F-2BF3393CD9A3@thebuild.com> <1715546791.171305.1689013799237@connect.xfinity.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox