| From: | Rip <rip(at)onlineinfo(dot)net> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re-write rules on views | 
| Date: | 2002-02-27 00:36:28 | 
| Message-ID: | 5.1.0.14.2.20020226192846.009ed850@mail.onlineinfo.net | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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,
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zak Greant | 2002-02-27 00:44:17 | Re: eWeek Poll: Which database is most critical to your | 
| Previous Message | cbbrowne | 2002-02-27 00:14:02 | Re: [ANNOUNCE] [pgsql-advocacy] eWeek Poll: Which database is most critical to your organization? |