Re: insert to projection

From: Brian <brian_at_selzer-software.com>
Date: Tue, 8 Sep 2009 05:39:01 -0700 (PDT)
Message-ID: <d3f8d652-89c2-456e-a5c3-a4468418c123_at_y9g2000yqn.googlegroups.com>


On Sep 4, 12:58 pm, paul c <toledobythe..._at_oohay.ac> wrote:
> Why do implementation languages not allow this?  Surely not for logical
> reasons?  We can delete from projection because NOT Pa implies NOT Pab,
> eg., <NOT> R{a} -> <NOT> R{a,b}.  Logically, we can insert to
> projections because Pab implies Pa.  Isn't the problem really a language
> deficiency?

Implementation languages do allow this. As long as the columns that are not in the view are either nullable or have a default constraint, then insert to projection is allowed. Here's an example:

CREATE TABLE ex
(
  K int NOT NULL ,

  A int NULL ,
  B int NULL ,
  C int NULL ,

  D int NOT NULL DEFAULT (0),
  PRIMARY KEY CLUSTERED (K)
)
go

create view exview as
  select K,A,B from ex
go

insert exview (K,A,B) VALUES (1,1,1)
go

select * from ex
go

Results:

K A B C D ----------- ----------- ----------- ----------- ----------- 1 1 1 NULL 0 (1 row(s) affected) Received on Tue Sep 08 2009 - 14:39:01 CEST

Original text of this message