Re: [SOLVED] Rules in views, how to?

From: Andre Lopes <lopes80andre(at)gmail(dot)com>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [SOLVED] Rules in views, how to?
Date: 2010-07-06 11:55:22
Message-ID: AANLkTikL5ADTX6SfO8R4pMJqRoBdDW-_dLbCVC5Cf2_z@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Thanks for the reply.

In the application there are two kinds of UPDATES to this table.

[code]
update aau_utilizadores
set group_id = 3
where email = pEMAIL;
[/code]

and

[code]
update aau_utilizadores
set password = 3
where id = pNEWPASSWORD;
[/code]

If I use the clause WHERE only in "id" will not work fot both cases, or will
work?

Best Regards,

On Tue, Jul 6, 2010 at 12:46 PM, Sam Mason <sam(at)samason(dot)me(dot)uk> wrote:

> On Tue, Jul 06, 2010 at 12:28:35PM +0100, Andre Lopes wrote:
> > Ok, I have done the UPDATE RULE like this and works!
>
> > where
> > (id = OLD.id or username = OLD.username or email = OLD.email)
>
> I'm pretty sure you just want to be using the id column above. Using an
> OR expression as you're doing could have some strange side effects.
>
> You may also want to consider a UNIQUE constraint on the username (and
> maybe email) fields as well, especially as you've said they should be
> able to be used to uniquely determine a user.
>
> --
> Sam http://samason.me.uk/
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2010-07-06 13:12:33 Re: [SOLVED] Rules in views, how to?
Previous Message Sam Mason 2010-07-06 11:46:08 Re: [SOLVED] Rules in views, how to?