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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-general by date

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