pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wiebe Cazemier <halfgaar@gmail.com>
To: Sarah Asmaels <sarah@spiesonline.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: writable joined view
Date: Tue, 25 Oct 2005 14:07:40 +0200
Message-ID: <435E200C.5090405@gmail.com> (raw)
In-Reply-To: <dj17je$7vu$1@news.spiesonline.net>
References: <dj17je$7vu$1@news.spiesonline.net>

Sarah Asmaels wrote:
> Hi!
> 
> I have one table referencing an object in another table through an ID,
> and a view joining those tables on the ID. I want to create rules to
> rewrite updates/deletes/inserts on the joined view to act on the real
> tables. Can you give me some pointers? The documentation has only
> examples for views depending on single tables.
> 
> Thank you,
> 
> Sarah

Is there any difference in multi or single table view? When you create a rule, 
you have access to NEW and/or OLD, which will contain all the fields your view 
has. You can then do something like this:

CREATE RULE insert_rule AS ON INSERT TO your_view DO INSTEAD (
	INSERT INTO table1 (name) VALUES (NEW.name);
	INSERT INTO table2 (favorite_color) VALUES (NEW.favorite_color);
);

Or is there something I'm not understanding about your request, or perhaps rules 
in general?



view thread (3+ messages)  latest in thread

Message-ID: <435E200C.5090405@gmail.com>
Permalink:  ../435E200C.5090405@gmail.com/
Also on:    postgresql.org/message-id/435E200C.5090405@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: halfgaar@gmail.com, sarah@spiesonline.net
  Subject: Re: writable joined view
  In-Reply-To: <435E200C.5090405@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox