pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: weigelt@metux.de
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: trigger/rule question
Date: Mon, 02 May 2005 09:58:04 +0200
Message-ID: <4275DD8C.EF29E7A1@rodos.fzk.de> (raw)
References: <20050427165624.GA4253@nibiru.borg.metux.de>
	<4270AC4F.6D62C9C8@rodos.fzk.de>
	<20050502034100.GE24546@nibiru.borg.metux.de>

Enrico Weigelt wrote:
> 
> * Christoph Haller <ch@rodos.fzk.de> wrote:
> 
> Hi,
> 
> > I assume this still refers to
> > [SQL] RULE for mtime recording
> > from last Friday.
> 
> ehm, yeah. I forgot that I've already asked this stuff ...
> hmmpf. seems I'm not getting younger ;-)
> 
> <snip>
> > I gave it another thought and
> > I am now having something which seems to work.
> > The trick is interpose a view to avoid the
> > rule recursion:
> 
> <big_snip />
> 
> correct me if I'm wrong:
> 
> you dont let the application write to the actual storage table, but
> instead to a view, which a modified write to the actual storage, where
> also the reads get their data from.

Exactly. 
> 
> okay, that's really an idea worth to think about :)
> 
> insert should work the same way. but how to implement delete ?
> (the application should only see one table, so in our case the view).

Exactly. 
> if we user "DO INSTEAD", we wont get anything to delete (AFAIK), so
> we cannot intercept here. the only chance seems to leave out "INSTEAD"
> and live with duplicate data.

No. What's wrong with (referring to my previous post) 

CREATE OR REPLACE RULE joo_delete 
AS ON DELETE TO joo_view 
DO INSTEAD 
DELETE FROM joo 
WHERE bar = OLD.bar ; 

DELETE FROM joo_view WHERE bar = '...' ; 

works perfectly for me 

Or did I miss something here? 
Regards, Christoph 

> 
> Did I miss anyting ?
> 
> cu
> --
> ---------------------------------------------------------------------
>  Enrico Weigelt    ==   metux IT service
>   phone:     +49 36207 519931         www:       http://www.metux.de/
>   fax:       +49 36207 519932         email:     contact@metux.de
> ---------------------------------------------------------------------
>   Realtime Forex/Stock Exchange trading powered by postgresSQL :))
>                                             http://www.fxignal.net/
> ---------------------------------------------------------------------
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
>                http://archives.postgresql.org



view thread (10+ messages)  latest in thread

Message-ID: <4275DD8C.EF29E7A1@rodos.fzk.de>
Permalink:  ../4275DD8C.EF29E7A1@rodos.fzk.de/
Also on:    postgresql.org/message-id/4275DD8C.EF29E7A1@rodos.fzk.de

 · 

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: ch@rodos.fzk.de, weigelt@metux.de
  Subject: Re: trigger/rule question
  In-Reply-To: <4275DD8C.EF29E7A1@rodos.fzk.de>

* 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