From: | "Brian Haney" <brian(at)cybernaut(dot)com> |
---|---|
To: | <pgsql-general(at)hub(dot)org> |
Subject: | update view |
Date: | 1999-11-27 08:16:48 |
Message-ID: | 000401bf38af$c04bab40$8101a8c0@specter.fresno.cybernaut.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm trying to update a table through a view and have read up on what
constitutes an 'updatable' view. I created a simple test case and cannot
get it to update the table through the view. In the transcript below,
notice that when I update the view, I get 'UPDATE 0' with no error message
or other complaints. What am I missing? Does PostgreSQL not support
updating through views?
-- Brian Haney
brian(at)cybernaut(dot)com
============================ BEGIN SAMPLE ========================
$ psql -f /tmp/viewtest test2
create table peanuts (
name text,
age int4,
height int4,
weight int4);
CREATE
insert into peanuts values ('Charlie Brown', 50, 24, 75);
INSERT 21228 1
insert into peanuts values ('Snoopy', 21, 18, 25);
INSERT 21229 1
insert into peanuts values ('Lucy van Pelt', 50, 27, 65);
INSERT 21230 1
insert into peanuts values ('Linus van Pelt', 50, 24, 75);
INSERT 21231 1
select * from peanuts;
name |age|height|weight
--------------+---+------+------
Charlie Brown | 50| 24| 75
Snoopy | 21| 18| 25
Lucy van Pelt | 50| 27| 65
Linus van Pelt| 50| 24| 75
(4 rows)
create view dogs as select * from peanuts where name = 'Snoopy';
CREATE
select * from dogs;
name |age|height|weight
------+---+------+------
Snoopy| 21| 18| 25
(1 row)
update dogs set age = 145;
UPDATE 0
select * from dogs;
name |age|height|weight
------+---+------+------
Snoopy| 21| 18| 25
(1 row)
EOF
$
From | Date | Subject | |
---|---|---|---|
Next Message | Stuart Rison | 1999-11-27 17:40:25 | Re: [GENERAL] can I do this. |
Previous Message | Mike Mascari | 1999-11-27 03:28:30 | Re: [GENERAL] update view |