Skip site navigation (1) Skip section navigation (2)

Re: How to determine field names in a trigger?

From: Justin Clift <jc(at)telstra(dot)net>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to determine field names in a trigger?
Date: 2004-06-29 06:36:17
Message-ID: 40E10DE1.4000201@telstra.net (view raw or flat)
Thread:
Lists: pgsql-general
Alvaro Herrera wrote:
<snip>
> I think you can do this very easily with PL/Tcl.  For a somewhat
> unrelated example, see General Bits issue #47,
> 
> http://www.varlena.com/GeneralBits/47.php
> 
> _I think_ there are examples closer to what you want to achieve in the
> archives.  The array of column names in a trigger is $TG_relatts.

Thanks Alvaro.

Didn't find any good examples in the archives (looked there before 
asking here), even though there are a few people over time asking the 
same question.

In PL/pgSQL at present (PG 7.4.3), I'm thinking the only approach may be 
to get the name of the table (TG_RELNAME) and then go and look up it's 
structure in pg_attribute or something (the same as shown by 
information_schema.columns).  Not sure how to do that either yet, and a 
better solution would be nifty.

PL/TCL does seem to provide that extra bit of info to functions/triggers 
that I need, whereas PL/pgSQL doesn't.  I'd prefer not to have to load 
further PL's into the database, but it's worth looking at anyway.

:)

Regards and best wisehs,

Justin Clift

> Hope this helps,
> 



In response to

Responses

pgsql-general by date

Next:From: CSNDate: 2004-06-29 06:56:15
Subject: dup(0) failed after 3195 successes: Bad file descriptor
Previous:From: Tom LaneDate: 2004-06-29 06:04:48
Subject: Re: Seeing uncommitted transactions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group