Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How make a view updateable?

Status
Not open for further replies.

edita

Programmer
Mar 26, 2003
14
PL
Hi,
I have two tables and I created a view on them. But when I open a view I cannot update anything. One of the column is primary key in one table and foreign in the second, other elements are not keys. My question is: what do I have to do to make a user able to update this view and tables which is made on?

Thanks for your help in advance :)
 
FYI - I don't know if you this applies to you but, in my experience, if you have "SELECT DISTINCT" or if you are using "SELECT TOP 100 PERCENT" along with an "order by" clause at the end your view will not be updateable.
 
You also cannot use any aggregate functions in the select list or the view will not be updateable. The view cannot use the keywords TOP, GROUP BY, UNION, or DISTINCT.

You can only update fields from one of the base tables in the view at a time even if the view is updateable. For instance, you have a view which joins two tables with one having a foriegn key referncing the other. You can't update the second table until the records are in the first table or you lose referntial integrity. Therefore, you must do two updates against the view to get all the fields updated. One to update the first table and one to update the related table. Often you also need some sort of intermediate step to get the identity field from the inserted record of the first table to use in the second.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top