Re: Help with function

From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: Chris Hoover <revoohc(at)sermonaudio(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Help with function
Date: 2005-06-09 20:03:15
Message-ID: 20050609200315.GH12706@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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)

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message James Herbers 2005-06-09 20:53:42 PostgreSQL default data location
Previous Message Chris Hoover 2005-06-09 18:17:24 Help with function