Re-write rules on views - Mailing list pgsql-general

From Rip
Subject Re-write rules on views
Date
Msg-id 5.1.0.14.2.20020226192846.009ed850@mail.onlineinfo.net
Whole thread Raw
Responses Re: Re-write rules on views  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi all,
    The docs seem slim in this department.. what is the proper syntax for an
update to a view with multiple tables?

Here's a view I'd like to update:

  CREATE VIEW "users_perms_view" AS
      SELECT
           users.user_id,
         users.username,
         users.name_first,
         users.name_last,
         permissions.permission_name,
         permissions.permission_description
      FROM
           users,
         users_permissions,
         permissions
      WHERE
           ((users_permissions.user_id = users.user_id) AND
         (users_permissions.permission_id = permissions.permission_id));

This rule works fine as far as it goes:

CREATE RULE "update_users_perms_view" AS
    ON UPDATE TO users_perms_view DO INSTEAD
    UPDATE
        users SET
          username = NEW.username,
        password = NEW.password,
        name_first = NEW.name_first,
        name_last = NEW.name_last,
        active = NEW.active,
    WHERE
        user_id = OLD.user_id;

How do I update the  users_permissions and  permissions table?

Thanx,


pgsql-general by date:

Previous
From: cbbrowne@acm.org
Date:
Subject: Re: [ANNOUNCE] [pgsql-advocacy] eWeek Poll: Which database is most critical to your organization?
Next
From: Zak Greant
Date:
Subject: Re: eWeek Poll: Which database is most critical to your