Re: Trigger Function question - Mailing list pgsql-general

From DAVID ROTH
Subject Re: Trigger Function question
Date
Msg-id 1715546791.171305.1689013799237@connect.xfinity.com
Whole thread Raw
In response to Re: Trigger Function question  (Christophe Pettus <xof@thebuild.com>)
Responses Re: Trigger Function question
List pgsql-general
I want to use a single trigger function to log multiple tables and the tables have different columns.  I can get the
namesof the columns from the catalog.  But I have not been able to figure out how to get NEW.x when x is not known
untilrun 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
catalogsto 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'tneed to change behavior based on the columns.
 



pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Trigger Function question
Next
From: Christophe Pettus
Date:
Subject: Re: Trigger Function question