From: wieck@debis.com
To: chris.bitmead@bigfoot.com
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] RV: A little problem updating data with views
Date: Sat, 5 Jun 1999 01:28:52 +0200 (MET DST)
Message-ID: <m10q3OO-0003kGC@orion.SAPserv.Hamburg.dsh.de> (raw)
In-Reply-To: <3757D393.EBDA5B70@bigfoot.com>
>
> I don't believe views are updatable in postgresql.
They are - if someone read the chapter on rules.
CREATE RULE vtest_upd AS ON UPDATE TO VTEST DO INSTEAD
UPDATE ttest SET t = new.t WHERE t = old.t;
It is just that those rules cannot simply be generated on the
fly while CREATE VIEW. In this simple case of course, but if
the view is a join of 3 tables, it's not clear how to update
them (if at all). So it's up to the DB designer to create
them by hand.
Jan
>
> Jorge Herrera Pi=F1ero wrote:
> >=20
> > Hello,
> >=20
> > We are using PostgreSQL v6.4 and have problems when we want update
> > data throught views.
> > When we issue an update statment within a view, always obtain 'UPDA=
> TE 0'
> > and the data is not updated. We have checked write permissions on v=
> iew
> > and are right.
> >=20
> > Any ideas was going wrong?
> >=20
> > thanks in advance.
> >=20
> > A complete UPDATE test:
> >=20
> > test=3D> create table ttest (t varchar(20), n int4);
> > test=3D> create view vtest as select t from ttest;
> > test=3D> insert into ttest values('asd', 0);
> > test=3D> select * from vtest;
> > t
> > ---
> > asd
> > (1 row)
> >=20
> > test=3D> grant all on ttest, vtest to postgres;
> > CHANGE
> >=20
> > test=3D> update vtest set t=3D'asdasd';
> > UPDATE 0
>
> --=20
> Chris Bitmead
> http://www.bigfoot.com/~chris.bitmead
> mailto:chris.bitmead@bigfoot.com
>
>
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck@debis.com (Jan Wieck) #
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: wieck@debis.com, chris.bitmead@bigfoot.com
Subject: Re: [SQL] RV: A little problem updating data with views
In-Reply-To: <m10q3OO-0003kGC@orion.SAPserv.Hamburg.dsh.de>
References: <3757D393.EBDA5B70@bigfoot.com> <m10q3OO-0003kGC@orion.SAPserv.Hamburg.dsh.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