Re: Rule Question

From: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>
To: Andrew Bartley <ambartley(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rule Question
Date: 2013-07-25 07:09:30
Message-ID: CAL_0b1vgX6vgE+fu5xVt6VjG=vtUwG4HZ_e30UCfjzUo=vXZ1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 24, 2013 at 11:44 PM, Andrew Bartley <ambartley(at)gmail(dot)com> wrote:
> Hope this question is not too stupid but......
>
> I am trying to do something like this
>
> create table cats (a text,b text);
>
> create rule cats_test as on update to cats do set a = new.b;
>
> Can i manipulate column "a" sort of like this... or is there a better way.
>
> I would like to do this as the construction of the new.b value is complex
> and time consuming, so I just want to do it once.
>
> update cats
> set b = something_complex_and_time_consuming(b);

AFAIK, the best way here is to use trigger that does new.a = new.b.

--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

Profile: http://www.linkedin.com/in/grayhemp
Phone: USA +1 (415) 867-9984, Russia +7 (901) 903-0499, +7 (988) 888-1979
Skype: gray-hemp
Jabber: gray(dot)ru(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vincenzo Romano 2013-07-25 07:14:04 Re: Why are stored procedures looked on so negatively?
Previous Message Luca Ferrari 2013-07-25 06:57:09 Re: Why are stored procedures looked on so negatively?