From: | Andre Lopes <lopes80andre(at)gmail(dot)com> |
---|---|
To: | Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> |
Cc: | postgresql Forums <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: [SOLVED] Rules in views, how to? |
Date: | 2010-07-06 11:28:35 |
Message-ID: | AANLkTikg-2AwYy1DXHe2aAmdcMPzpdK2qOOvIeVDyvBo@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ok, I have done the UPDATE RULE like this and works!
[code]
update atau_utilizadores
set group_id = NEW.group_id,
password = NEW.password,
salt = NEW.salt,
email = NEW.email,
activation_code = NEW.activation_code,
forgotten_password_code = NEW.forgotten_password_code,
remember_code = NEW.remember_code,
created_on = NEW.created_on,
last_login = NEW.last_login,
active = NEW.active
where
(id = OLD.id or username = OLD.username or email = OLD.email)
[/code]
Best Regards,
On Tue, Jul 6, 2010 at 12:03 PM, Andre Lopes <lopes80andre(at)gmail(dot)com> wrote:
> Hi Alban,
>
> But in my application I have more than one way of uniquely identify the
> record. Could be by the email field or by the id field.
>
> Thera are update that are done by the WHERE email clause and other by the
> WHERE id clause.
>
> It is possible to deal with this?
>
> Best Regards,
>
>
>
>
>
> On Tue, Jul 6, 2010 at 11:54 AM, Alban Hertroys <
> dalroi(at)solfertje(dot)student(dot)utwente(dot)nl> wrote:
>
>> On 6 Jul 2010, at 12:28, Andre Lopes wrote:
>>
>> > Now I need also to add an INSTEAD UPDATE rule and an INSTEAD DELETE
>> rule, but I have some doubts about it... let me explain...
>> >
>> > Ok, I need to create an INSTEAD UPDATE rule in this view, but I don't
>> know how to use the clause WHERE in the UPDATE rule. For example the UPDATE
>> could be done when "WHERE email = 'X' " or "WHERE id = 'Y' ".
>> >
>> > Question: How can I deal with this?
>>
>>
>> In the WHERE-clause you use the columns from the OLD record that uniquely
>> identify that record.
>>
>> Alban Hertroys
>>
>> --
>> Screwing up is an excellent way to attach something to the ceiling.
>>
>>
>> !DSPAM:921,4c330b7e286211912975436!
>>
>>
>>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Lew | 2010-07-06 11:39:03 | Re: moderninzing/upgrading mail list format |
Previous Message | Andre Lopes | 2010-07-06 11:03:38 | Re: Rules in views, how to? |