| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Luis Sousa <llsousa(at)ualg(dot)pt> |
| Cc: | pgsql sql Mailing List <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: Problems using a rule with the WHERE clause |
| Date: | 2001-06-25 18:01:11 |
| Message-ID: | 16743.993492071@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Luis Sousa <llsousa(at)ualg(dot)pt> writes:
> CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
> WHERE OLD.idpessoal != 0
> DO INSTEAD (
> ...
> When I execute the INSERT into de view docentesturno I got the message:
> ERROR: Cannot update a view without an appropriate rule
You failed to supply a rule covering the case OLD.idpessoal = 0.
More specifically, you *must* supply an unconditional INSTEAD rule to
replace the attempt to insert/update in the view. Possibly what you
want is
CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
WHERE OLD.idpessoal != 0
DO ( ... );
CREATE RULE "updateturnodocente_default" AS ON UPDATE TO "docentesturno"
DO INSTEAD NOTHING;
Here, the unconditional rule always fires, and the conditional one fires
only when its condition is true.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Josh Berkus | 2001-06-25 22:37:39 | Re: select with multiple occurences in same table |
| Previous Message | Wei Weng | 2001-06-25 17:19:45 | control structure in a transaction block? |