Restrictions on updating views  group by or compute in a view definition

Chapter 11: Views: Limiting Access to Data

Computed columns in a view definition

This restriction applies to columns of views that are derived from computed columns or built-in functions. For example, the amt_due column in the view accounts is a computed column.

create view accounts (title_id, advance, amt_due) 
as select titles.title_id, advance, 
(price * royalty/100) * total_sales 
from titles, roysched 
where price > $15 
  and advance > $5000 
and titles.title_id = roysched.title_id 
and total_sales between lorange and hirange 

The rows visible through accounts are:

select * from accounts
title_id     advance     amt_due 
--------     --------    --------- 
PC1035       7,000.00    32,240.16 
PC8888       8,000.00     8,190.00 
PS1372       7,000.00       809.63 
TC3218       7,000.00       785.63 
 
(4 rows affected) 

updates and inserts to the amt_due column are not allowed because there is no way to deduce the underlying values for price, royalty, or year-to-date sales from any value you might enter in the amt_due column. delete operations do not make sense because there is no underlying value to delete.





Copyright © 2005. Sybase Inc. All rights reserved. group by or compute in a view definition

View this book as PDF