pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@surnet.cl>
To: Chris Hoover <revoohc@sermonaudio.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Help with function
Date: Thu, 9 Jun 2005 16:03:15 -0400
Message-ID: <20050609200315.GH12706@surnet.cl> (raw)
In-Reply-To: <MAILSERVERrOE9TuHZn00000436@mail.astudios.com>
References: <MAILSERVERrOE9TuHZn00000436@mail.astudios.com>

On Thu, Jun 09, 2005 at 06:17:24PM +0000, Chris Hoover wrote:
> I am trying to write a very generic function to be used for table auditing.  I am kind of stuck on how to make the function use the column names I pull from the db.  Is there anyway to do what I have below?  My main concern is this segment:
> 
> if (new.columnName != old.columnName or
>         (old.columnName is null and new.columnName is not null) or
>         (old.columnName is not null and new.columnName is null)
>        ) then
> 
> How can I get PostgreSQL to substitute the selected column name for the old.columnName/new.columnName?

Standard answer has been "can't do that in plpgsql".  You may want to
try pl/perl, pl/python (does that support triggers?) or pl/tcl.

If performance is an issue, write the function in C.

-- 
Alvaro Herrera (<alvherre[a]surnet.cl>)
"If it wasn't for my companion, I believe I'd be having
the time of my life"  (John Dunbar)



view thread (7+ messages)  latest in thread

Message-ID: <20050609200315.GH12706@surnet.cl>
Permalink:  ../20050609200315.GH12706@surnet.cl/
Also on:    postgresql.org/message-id/20050609200315.GH12706@surnet.cl

 · 

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-admin@postgresql.org
  Cc: alvherre@surnet.cl, revoohc@sermonaudio.com
  Subject: Re: Help with function
  In-Reply-To: <20050609200315.GH12706@surnet.cl>
  References: <MAILSERVERrOE9TuHZn00000436@mail.astudios.com> <20050609200315.GH12706@surnet.cl>

* 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