January 13, 2005 at 10:02 pm
Is there a way to determine if a view is updatable (before attempting INSERT/UPDATE/DELETE and having the error occur)?
I was hoping to find something like
OBJECTPROPERTY(OBJECT_ID('my_view'),'IsUpdatable')
but that property doesn't exist.
Any other ideas or suggestions on how to do this?
January 14, 2005 at 4:54 am
AFAIK, there is no easy way to determine if a view is updateable or not.
The first 'problem' is - what is an updateable view? There may be several different definitions to this, depending on the decided rules.
eg - you update through a view, and the update then causes this piece of data to not be seen anymore through the view. If the view is compiled with WITH CHECK OPTION this particular effect will be disallowed, while other updates will be allowed. Should the view be considered updateable or not in this case?
The view DDL might itself look a certain way that makes it impossible to update through it - but.. there may exist an INSTEAD OF TRIGGER on the view that will make it updateable anyway.
If it is a partitioned view, it may, or may not be updatable.
If it is a 'normal' view, it may, or may not be updatable depending on a number of things..
-- short snip from BOL --
If a view does not have INSTEAD OF triggers, or if it is not a partitioned view, then it is updateable only if the following conditions are satisfied:
-- end BOL --
As you can see it seems a daunting task to determine this 'on the fly' so to speak. I think that the best thing is to only attempt modifications (insert/update/delete) on views that are purposefully designed and tested for it, not otherwise.
/Kenneth
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply