Groups | Blog | Home
all groups > sql server programming > july 2004 >

sql server programming : Updatable view


Joe Celko
7/16/2004 4:14:15 PM
[quoted text, click to view]
selecting a constant value. <<

When a value is not provided, the columns needs to have a DEFAULT to
use. Your choices are (1) copy all the procedures and add the campus
name to their name, then put in the appropriate constant for that campus
or (2) use some kind of INSTEAD OF trigger on the VIEWs that has the
targeted campus.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
John Bell
7/16/2004 9:19:40 PM
Hi

You may want to look at an INSTEAD OF INSERT trigger.

John

[quoted text, click to view]

Henrik Johansson
7/16/2004 9:39:37 PM
Our schedule management system for the university runs as one database for
each campus.
We want to consolidate the databases to one single database for alot of
reasons, but we have for the moment no possibility to modify the app to fit
the requirements for "intercampus work".
Until the app is modified to support the extra field which tells what campus
the data belongs to, I thaught that we could maybe use updatable views in
each campus database collecting data from tables in a common database and by
that way trick the app that it has the data in the database it work with.

create view datatbl as
select campus='a',datacolumns...
from commondb..datatbl
where campus='a'

This works for update, but will not work for insert/delete because of
selecting a constant value.
Insert requires "select campus,datacolumns..." to work, but that will try to
insert a null-value into the campus-field when the app isn't sending that
column value and fail when the field doesn't allow null.

The campus name can be found in another table, but trying to use join to get
that information returns the same error as when using a constant value.

Any solution for my problem?
/Henrik

Aaron [SQL Server MVP]
7/17/2004 11:48:03 AM
[quoted text, click to view]

Or update the app and stop allowing direct insert/update access to the
tables.

--
http://www.aspfaq.com/
(Reverse address to reply.)

Henrik Johansson
7/17/2004 2:46:36 PM
(1) could be a solution if I had some procedures to edit.
There's only procedures for deleting, but there's by some reason no
procedure for insert/update which is done by direct access to the db tables.

I think I'll nead to read up on INSTEAD OF triggers, which sounds to be the
solution.
/Henrik

[quoted text, click to view]

AddThis Social Bookmark Button