| From: | Leif Jensen <leif(at)crysberg(dot)dk> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Cc: | Brian Grønborg <bg(at)crysberg(dot)dk> |
| Subject: | Newbie question on RULEs .. or .. bug ? |
| Date: | 2005-05-17 13:14:12 |
| Message-ID: | Pine.LNX.4.58.0505171452550.10945@samba.crysberg.dk |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hello,
I have been working with a great database system called PostgreSQL for
many years ;-) but never had to use any RULEs. I now have to use and
update through a view and have written a few rules to make this possible
as per the manual.
My insert rules seems to work fine, but I can't make the update rule do
what I want and as I believe stated in the manual.
In the attached schema I have 2 basic tables and a view combining
those. I have 2 rules for insert on the view and these works fine. The
update rule, however, doesn't do what I want. The manual states that the
origsal query tree (where) is added to the rule qualification,
so I would exspect the update statement below would only update 1 row of
the ganntinfo table, but it updates all 5 ?
What am I doing wrong ?
projtaskdb=# SELECT * FROM ganntinfo ;
id | seq | category | name
-----+-----+----------+---------
46 | 0 | SRC | 2WWE
172 | 0 | SRC | RKD60
138 | 0 | SRC | Diverse
34 | 0 | SRC | VF
87 | 0 | SRC | 2WWE
(5 rows)
projtaskdb=# UPDATE tasks SET id = 87, category = 'SRC', name = '2WWE',
customer = 'Custm', description = 'test' WHERE id = 87 and category =
'SRC';
UPDATE 5
projtaskdb=# SELECT * FROM ganntinfo ;
id | seq | category | name
----+-----+----------+------
87 | 0 | SRC | 2WWE
87 | 0 | SRC | 2WWE
87 | 0 | SRC | 2WWE
87 | 0 | SRC | 2WWE
87 | 0 | SRC | 2WWE
(5 rows)
projtaskdb=#
I tried to put an 'explain' in front of the update within the update
rule, but got a syntax error. Why is that ?
Please help,
Leif
| Attachment | Content-Type | Size |
|---|---|---|
| projtaskdb-test.sch | text/plain | 1.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | ElayaRaja S | 2005-05-17 13:23:07 | Help - Urgent |
| Previous Message | Patrick.FICHE | 2005-05-17 12:46:05 | Re: Password Encryption / PgAdmin |