From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Andy Dale <andy(dot)dale(at)gmail(dot)com> |
Cc: | pgsql general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Generic triggers ? |
Date: | 2007-04-24 15:42:12 |
Message-ID: | 20070424154212.GF2579@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Apr 24, 2007 at 05:35:09PM +0200, Andy Dale wrote:
> Hi,
>
> I wanted to setup a simple "generic" type trigger. What a mean by generic
> is that i don't want to hardcode the
> NEW.<column> or OLD.<column> calls, i searched for a way to loop over
> the NEW/OLD rowtypes but could not figure out how it should be done.
You're trying to do something that pl/pgsql it notoriously bad at. I
suggest you use some more dynamic language like perl/python/etc.
> The above code does nothing useful and is only to test out the concept. The
> problem comes from NEW.colnames[i] because the NEW rowtype does not have a
> column called colnames. Can anyone tell me how to append the value of
> colnames[i] to NEW so it would work, or is it even possible to iterate of
> the NEW/OLD rowtype without having to know the column names ?
Not in pl/pgsql (being statically typed). In some other languages you can.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2007-04-24 15:44:11 | Re: Generic triggers ? |
Previous Message | Richard Huxton | 2007-04-24 15:41:43 | Re: View is not using a table index |