Views derived from other views  View resolution

Chapter 11: Views: Limiting Access to Data

Retrieving data through views

When you retrieve data through a view, Adaptive Server checks to make sure that all the database objects referenced anywhere in the statement exist and that they are valid in the context of the statement. If the checks are successful, Adaptive Server combines the statement with the stored definition of the view and translates it into a query on the view’s underlying tables. This process is called view resolution.

Consider the following view definition statement and a query against it:

create view hiprice 
as select * 
from titles 
where price > $15 
and advance > $5000 
select title, type 
from hiprice 
where type = "popular_comp" 

Internally, Adaptive Server combines the query of hiprice with its definition, converting the query to:

select title, type 
from titles 
where price > $15 
and advance > $5000 
and type = "popular_comp" 

In general, you can query any view in any way just as if it were a real table. You can use joins, group by clauses, subqueries, and other query techniques on views, in any combination. However, if the view is defined with an outer join or aggregate function, you may get unexpected results when you query the view. See “Views derived from other views”.

NoteYou can use select on text and image columns in views. However, you cannot use readtext and writetext in views.





Copyright © 2005. Sybase Inc. All rights reserved. View resolution

View this book as PDF