Re: How to determine field names in a trigger? - Mailing list pgsql-general

From Justin Clift
Subject Re: How to determine field names in a trigger?
Date
Msg-id 40E10DE1.4000201@telstra.net
Whole thread Raw
In response to Re: How to determine field names in a trigger?  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Responses Re: How to determine field names in a trigger?  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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,
>



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Seeing uncommitted transactions
Next
From: "Najib Abi Fadel"
Date:
Subject: dividing time ??